Mika Helander
Sep 6, 2018 · 1 min read
const strFloatToInt = compose(Math.round, parseFloat)
const trance = compose(
mapping(strFloatToInt),
filtering((x) => 20 < x)
);
[ '10', '11', '21', '20.4' ].reduce(
trance((acc, x) => acc.concat(x)),
[]
);

As trance is interesting, mind explain why this version behaves like it’s using pipe?

I’ll do it then… as composedoes reverse mapping of the argument functions, chaining of the action reducers is from result collector ((acc, x) => acc.concat(x)) to filtering, filtering reducer to mapping and thus actor functions are called in reversed order per array item.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade