purely functional calculator using recursion over lists