27 Nov
2002
27 Nov
'02
4:02 p.m.
Doesn't seem that usefull to me, you can get the several consecutive ones by applying tails to your list.
I want to propose the following function slide, which is like map, but depends not on one value of a list, but on several consecutive ones.
slide :: ([a] -> b) -> [a] -> [b] slide f [] = [] slide f xs = f xs : slide f (tail xs)
slide f = map f.init.tails The init is needed because you don't apply f to the empty List. If you did, then it would be just.
slide :: ([a] -> b) -> [a] -> [b] slide f [] = f [] <--------------- slide f xs = f xs : slide f (tail xs)
slide f = map f.tails J.A.