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
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#