Simple Question

Jerry, JiJie jerry@gime.com
Thu, 16 May 2002 21:33:52 +0800


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' :: [[a]] -> a -> [[a]]
19) append' [] y = [[y]]
20) append' x:xs y = [(init x:xs)] ++ [(tail xs)++[y]]

and ghc(5.02.3) says:

$ ghc p3a.hs 
p3a.hs:20: Parse error in pattern

thanx in advance!

-- 
Regards,
Jerry