Hi
f1 :: [Int] - [[Int]]
f1 [] = []
f1 (a:as) = [a] : f1 as
f1 is simply a map
f3 la lb = let a = head la
b = head lb
in if sum a = sum b then
a : f3 (tail la) lb
else
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
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
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
Another way to express f1 with map is:
f1 xs = map (\x -
On 12/29/06, Neil Mitchell [EMAIL PROTECTED] wrote:
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
|
Hi all,
I have this function which combines (zip) list of sorted lists into a sorted
list (sorted by sum). The function works with infinite list and seems to
give correct result. But after I see the code for the Hamming sequence from
the Wiki, I wonder if it can be written better, or more