Simple Question

2002-05-16 Thread Jerry, JiJie
Hi, enlightenment much appreciated for my newbie question -- to achieve: append' [ [1, 2], [3, 4], [5] ] 6 - [ [1, 2], [3, 4], [5, 6] ] append' [ ['1', '2'], ['3'] ] '4' - [ ['1', '2'], ['3', '4'] ] append' [ [True], [True] ] False - [ [True], [True, False] ] so I (naively) write: 18) append'

Re: Simple Question

2002-05-16 Thread Ch. A. Herrmann
Hi, JiJie 20) append' x:xs y = [(init x:xs)] ++ [(tail xs)++[y]] function application (blank) binds stronger than :, thus you should write append' (x:xs) y = ... Cheers -- Christoph ___ Haskell-Cafe mailing list [EMAIL PROTECTED]

Simple Question Follow Up

2002-05-16 Thread Jerry, JiJie
* Ch. A. Herrmann [EMAIL PROTECTED] [020516 21:38]: Hi, JiJie 20) append' x:xs y = [(init x:xs)] ++ [(tail xs)++[y]] function application (blank) binds stronger than :, thus you should write append' (x:xs) y = ... -- so I added the parenthesis: 18) append' :: [[a]] - a -

Re: Simple Question Follow Up

2002-05-16 Thread Ch. A. Herrmann
To make it short: Main let append' xs y = init xs ++ [last xs ++ [y]] This works for the three given examples but maybe incorrect for the task you have in mind, e.g., if xs is empty. Main append' [ [1, 2], [3, 4], [5] ] 6 [[1,2],[3,4],[5,6]] Main append' [ ['1', '2'], ['3'] ] '4' [12,34] Main