[–] juliangamble 12y ago ↗ Some gems in thereFirst, 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)
1 comment
[ 2.3 ms ] story [ 8.8 ms ] threadFirst, 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)