Possible Duplicate:
Why is such a function definition not allowed in haskell?
I would like to create a function flist that takes a function f as argument and returns another function whose argument will be a list but behaves exactly same as f.
For example:
let f x1 x2 x3 = x1+ x2 + x3
I want this behaviour
(flist f) [x1,x2,x3] = x1+x2+x3
When the list is not of length 3 it may behave in any way. flist should take care of any function (not only functions with 3 argument, i.e. if g x1 x2 x3 x4 = x1+x2+x3*x4, then (flist g) [x1,x2,x3,x4] = x1+x2+x3*x4 ).
I tried this,
flist f [] = f
flist f (x:xs) = flist (f x) xs
But it is not working. How do I achieve this? Can I use data types to do this?