Define your own recursion in JavaScript with Pattern Matching and Functional Programming
pattern is a way to do pattern matching in javascript that helps you with asynchronous iterations
map(_, [], ac, cb,
function map_done(f, l, ac, cb) { return cb(ac); });
map(f, l, ac, cb,
function map_catch_all(f, l, ac, cb) {
ac.push(f(l.shift())); // head
map(f, l, ac, cb); // l is now tail
});
If you understand this, you will like pattern!
Written by Nuno Job
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#