I have a problem with implementing FP (Backus) interpreter in Haskell.
FP functions look like this:
[+,*]:<2,3>
should result with
<+:<2,3>, *:<2,3>> ->
<5,6>
meaning that every function from list on left side should be performed on every every element of a list on a right side.
What I understand is that I need something similar to "map" function, but map applies one function on a list, and I need list of functions on a list of values.
Thank you in advance! :-)
EDIT:
Since I wasn't precise, here is my code that doesn't work:
apply :: [String] -> [Integer] -> [Integer]
apply fs v = [((apply_f f x) | f <- fs | x <- v)]
apply_f :: String -> [Integer] -> [Integer]
apply_f "+" v = [(sum v)]
apply_f "*" v = [(product v)]
I can't figure out why... :-(
EDIT 2:
Sorry, I was too tired from working all day on this. Problem is that I don't need second pipe, just first one:
apply fs v = [ apply_f f v | f <- fs ]
Now, everything works just fine, thank you very much! :-)