Created
January 4, 2017 18:41
-
-
Save jethrolarson/faccf066b0b1bfa08dc75f9db6788673 to your computer and use it in GitHub Desktop.
Loop fusion with transducers in Ramda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {into, pipe, filter, map, propEq, prop} from 'ramda'; | |
const doStuff = pipe( | |
filter(propEq('status', 'active')), | |
map(prop('age')) | |
); | |
// only iterates array once | |
into([], doStuff, [{status: 'active', name: 'Pam'}, {status: 'bad', name: 'Mancy'}]); | |
// ['Pam'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment