
4 Nov
2006
4 Nov
'06
3:25 a.m.
Hello libraries, similar to mapFst and Co, we can define: -- |Map various parts of list mapHead f [] = [] mapHead f (x:xs) = f x : xs mapTail f [] = [] mapTail f (x:xs) = x : map f xs mapInit f [] = [] mapInit f xs = map f (init xs) : last xs mapLast f [] = [] mapLast f xs = init xs : map f (last xs) btw, two last operations may be a bit slow. it's possible to define initLast function that returns both parts and still lazy? -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com