Re:Trine – A utility library for functional programming in J...
by quinnirill on Friday June 12, 2015 @01:56AM
(#9704286)
With Trine this would be
and then later:
Granted, the `flatten` function is not in the Trine yet, somehow forgot that from the initial release.
[ Parent
| on HN ]
Re:Trine – A utility library for functional programming in J...
by CrossEye on Friday June 12, 2015 @08:39AM
(#9705449)
Ok, that helps make it a bit more palatable to me.
Thanks for the information.
One question, though: How do user functions interact in here? If you didn't include `flatten`, but I had my own version of it, would it be straightforward for me to build `process` using my own `flatten`? Do I have to modify some Trine objects, or can I use some simple function references?
Obviously I haven't yet actually dug into the Trine code. Perhaps this weekend.
Re:Trine – A utility library for functional programming in J...
by quinnirill on Friday June 12, 2015 @01:28PM
(#9707306)
Happy to help!
Yes, you can use just simple function references, e.g. you could just define flatten as so
function * flatten () {
for ( const item of this ) {
yield * item;
}
}
And it would work just like it was part of Trine - in fact that's probably how it's going to be implemented in Trine. The chaining is not a feature of Trine, but the function bind syntax proposal ( https://github.com/zenparsing/es-function-bind ), Trine has merely been designed to work well with this syntax.