fold - Where's foldl1 and foldr1 in Racket? -


racket has foldl , foldr, require initial value. haskell in addition has foldl1 , foldr1, instead of applying function on initial value , first element, applies first , second element. implemented them as:

(define (foldl1 f xs)   (foldl f (first xs) (rest xs))) 

is there better way?

there better way, (require srfi/1) , use reduce , reduce-right. :-d


Comments

Popular posts from this blog

css - I want to align grid in center -

Contact Form PHP Email Script -

python - SWIG function not printing output -