I have built this function which calls a couple other functions to get the oprator and numbers for an arithmetic operation but I get the error function call: expected a function after the open parenthesis, but received '+. normaly you invoke addition as (+ 5 6) and multiplication as (* 4 9) ect. So I thought you could call a function that would get each piece but I cant seem to get it to work. Here is what I have:
Ideally you'd make it so that the list contains + instead of '+ in the first place. If that's not possible (because you have no control over the lists), you could either use eval or a map or associative list that maps the symbols to their corresponding functions depending on your exact needs.
Because '(foo bar baz) is the same as (list 'foo 'bar 'baz) and since numeric constants are self-evaluating, '2 and '3 are just equal to 2 and 3, so the whole thing comes out as (list 2 '+ 3) (i.e. a list containing the number 2, the symbol + and the number 3).
So if that's your input, you'll need one of those options that I mentioned - or just a boring list of conditions like (equal? op '+), (equal? op '-) etc.