Re: [Haskell-cafe] Combine list of sorted lists

2006-12-29 Thread Quan Ta
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 |

Re: [Haskell-cafe] Combine list of sorted lists

2006-12-29 Thread Bryan Burgers
> 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 (

Re: [Haskell-cafe] Combine list of sorted lists

2006-12-29 Thread David House
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.

Re: [Haskell-cafe] Combine list of sorted lists

2006-12-29 Thread Neil Mitchell
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 l

Re: [Haskell-cafe] Combine list of sorted lists

2006-12-29 Thread Quan Ta
On 12/29/06, Neil Mitchell <[EMAIL PROTECTED]> wrote: 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 >

Re: [Haskell-cafe] Combine list of sorted lists

2006-12-29 Thread Neil Mitchell
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

[Haskell-cafe] Combine list of sorted lists

2006-12-28 Thread Quan Ta
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 clear