Racket has only foldl
and foldr
, which require initial value. Haskell in addition has foldl1
and foldr1
, which instead of applying a function on the initial value and the first element, applies to first and second element. Currently i implemented them as:
(define (foldl1 f xs)
(foldl f (first xs) (rest xs)))
Is there a better way?