Sorry to Neil for multiple copies.
On 29/12/06, Neil Mitchell <[EMAIL PROTECTED]> wrote:
> I am not sure how to express f1 with map? how do I say
> (lambda (ls)
> (map (lambda (x) (list x))
> ls))
> in Haskell? map ([]) ?
map (:[]), :[] takes a single element and puts it into a list. Some
people refer to this as "box"
You can pretty much directly translate your Lisp:
\ls -> map (\x -> [x]) ls
Which eta-reduces to:
map (\x -> [x])
Now the inner lambda can be written as:
\x -> x : []
Or,
(: [])
That's a section on the ':' operator. So the whole thing becomes:
map (:[])
Hope that helps.
--
-David House, [EMAIL PROTECTED]
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe