[Haskell-beginners] How do I determine if a list created using a lambda expression is null?

Costello, Roger L. costello at mitre.org
Mon Oct 24 22:21:46 CEST 2011


Hi Folks,

I have a lambda expression that can be used to construct a list of values:

cons = (\a -> (\b -> (\f -> f a b)))

Here is an example that uses cons to construct "hello"

hello = cons 'h' (cons 'e' (cons 'l' (cons 'l' 'o')))

And here is a lambda expression that returns the tail of a list created using cons:

tail' = (\c -> c (\a -> (\b -> b)))

I would like to create a function that computes the length of a cons-created list:

length' = \xs -> if ( null' xs ) then 0 else length' (tail' xs) + 1

How would I define null' to determine if a cons list is empty?

null' = ???


/Roger



More information about the Beginners mailing list