Calculator implemented in scala