Skip to content

Instantly share code, notes, and snippets.

@jethrolarson
Created January 4, 2017 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jethrolarson/faccf066b0b1bfa08dc75f9db6788673 to your computer and use it in GitHub Desktop.
Save jethrolarson/faccf066b0b1bfa08dc75f9db6788673 to your computer and use it in GitHub Desktop.
Loop fusion with transducers in Ramda
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