I have a Scheme function that calculates sequence differences, i.e., it returns
a sequence that is the difference between the 2nd and the 1st element, the 3rd
and the 2nd, the 4th and the 3rd, etc.
(define s
(lambda (f l)
(cond ((null? (cdr l)) '())
(else (cons (f (cadr l) (car l))
(s f (cdr l)))))))
where
(s - '(0,1,3,6,10,15,21,28)) => (1,2,3,4,5,6,7)
I'm thinking the same function in Haskell would be something like
s ::
s f [] = []
s f [x] = [x]
s f l = [ a f b | (a,b) <- zip (init l) (tail l)]
but can't figure out what the function typing would be.
Michael
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe