Sha256: 97beb29f55c84131a16d0765f0d2cde0b6e47b098d88fc578cffe35ef297bf5a
Contents?: true
Size: 461 Bytes
Versions: 84
Compression:
Stored size: 461 Bytes
Contents
module Accumulate (accumulate) where accumulate :: (a -> b) -> [a] -> [b] accumulate _ [] = [] accumulate f (x:xs) = f x : accumulate f xs {- -- Some other reasonable definitions: accumulate f = foldr ((:) . f) [] accumulate f xs = [f x | x <- xs] -- Commonly submitted inefficient solution (we test for this now): accumulate f = accumulate' [] where accumulate' acc [] = reverse acc accumulate' acc (x:xs) = accumulate' (f x : acc) xs -}
Version data entries
84 entries across 84 versions & 1 rubygems