[Haskell-cafe] calling a variable length parameter lambda expression

Ketil Malde ketil at malde.org
Tue May 5 14:53:41 EDT 2009


Nico Rolle <nrolle at web.de> writes:

> A function is recieving a lambda expression like this:
> (\ x y -> x > y)
> or like this
> (\ x y z a -> (x > y) && (z < a)

And the type of that function is..?

> my problem is now i know i have a list filled with the parameters for
> the lambda expression.   but how can i call that expression?

> [parameters] is my list of parameters for the lambda expression.
> lambda_ex is my lambda expression

Would this work?

  data LambdaExpr a = L0 a | L1 (a -> a) | L2 (a -> a -> a) | ...

  apply :: LambdaExpr a -> [a] -> a
  apply (L0 x) _ = x
  apply (L1 f) (x:_) = f x
  apply (L2 f) (x1:x2:_) = f x1 s2
   :

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants


More information about the Haskell-Cafe mailing list