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

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -