4 ms·
Some gems in there First, we have to realise that many array (or other collection) operations like map, filter and reverse can be defined in terms of a reduce.
by juliangamble 12y ago
Some gems in there
First, we have to realise that many array (or other collection) operations like map, filter and reverse can be defined in terms of a reduce.
...
To get at the reducing functions, we need to make map and filter more generic by extracting the pieces they have in common:
- Use of collection.reduce
- The 'seed' value is an empty array
- The concat operation performed on result and the input (transform-ed or not)
...
Before we do that, we need a new function: identity. It simply returns whatever it is given:
(Although there is a lot that may be obvious to the Haskell guys)