News for hackers. Stuff that matters.
Re:Fun.js – Just a sketch by tomTheBom on Thursday June 06, 2013 @10:13PM (#5836718)
Very interesting post but I'm having trouble with one thing. pipeline(5) returns 5. When I try to follow that path, I get to this: reduce(function(l,r) { return r(l); }, seed, funs) with seed=5 and funs=[] (an empty array). How does that reduction evaluate to 5? In other words, what is "r(l)" when l=5 and r=the first member of an empty array?
Re:Fun.js – Just a sketch by fogus on Thursday June 06, 2013 @11:47PM (#5837101)
In reduce the accumulator starts as the seed and is changed in the forEach for each elem. Since there are so elems (funs) the accumulator never changes and returns as the value of seed (5).
Re:Fun.js – Just a sketch by tomTheBom on Friday June 07, 2013 @10:14AM (#5838986)
Of course. Shoulda seen that. ;) forEach on an empty collection returns immediately. Thanks.