Commonly Used List Processing Functions in FP
A list of commonly used functions for processing collections in FP languages or when adopting an FP style. Grouped by language in alphabetical order. The listing order for the functions is the same for every language. Some functions, though, are missing in some languages or there are alternative ways to accomplish the same goal.
Clojure
first
rest
map
filter
or its dualremove
every?
or its dualnot-every?
some
or its dualnot-any?
zipmap
zip-with
. There's no such function in Clojure, but the same thing can be achieved by passing at least two collections tomap
.take
take-while
drop
drop-while
reduce
Please note that some of the functions above will probably be superseded by the new reducers library.
Erlang
hd/1
tl/1
lists:map/2
lists:filter/2
lists:all/2
lists:any/2
lists:zip2/2
andlists:zip3/3
lists:takewhile/2
lists:dropwhile/2
lists:foldl/3
lists:foldr/3
Haskell
head
tail
map
filter
all
or the closely relatedand
any
or the closely relatedor
zip
or any of thezip3
up tozip7
in theData.List
modulezipWith
or any of thezipWith3
up tozipWith7
in theData.List
moduletake
drop
takeWhile
dropWhile
foldl
foldr
JavaScript (using underscore.js)
first
rest
map
filter
and its dualreject
all
any
zip
reduce
/inject
/foldl
reduceRight
/foldr