Permalink
Browse files

Update README.md

  • Loading branch information...
dscape committed Aug 11, 2012
1 parent dadd6ab commit 056a563a0d87c4df28082ad656ebe64ffc7c4c8a
Showing with 16 additions and 0 deletions.
  1. +16 −0 README.md
View
@@ -3,6 +3,22 @@
`pattern` is a way to do pattern matching in javascript that helps you with asynchronous iterations
+``` js
+var map = require('../pattern')()
+ , _, f, ac
+ ;
+
+map(f, [], ac, function done(_, _, ac) { return console.error(ac); });
+map(f, _, ac, function all(f, l, ac) {
+ ac.push(f(l.shift())); // head
+ map(f, l, ac); // l is now tail
+});
+
+map(function plusone(x) { return x+1; }, [1,2,3], []);
+```
+
+## explanation
+
``` js
// check `samples/nodetuts.js` for working code
insert_all([], function () { console.log('done'); });

0 comments on commit 056a563

Please sign in to comment.