Hi Quan

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"

The final f3 clause can be made a bit neater:

f3 la@(a:as) lb@(b:bs) | sum a <= sum b = a : f3 as lb
                                   | otherwise = b : f3 la bs

Additionally, if it was me I'd refer to a:as on the RHS, rather than
giving it a name with the @ pattern, but thats a personal question of
style.

Thanks

Neil
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to