This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function foreach(a, f) { | |
| var total, | |
| i; | |
| for (i = 0, total = a.length; i < total; i++) { | |
| f(a[i]); | |
| } | |
| } | |
| function Propagate(value){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /**Note: This works in Firefox Nightly but not in Chrome (shame on you!)**/ | |
| var s = { | |
| concat: function(a, b) { | |
| return a.concat(b); | |
| }, | |
| map: function(a, f) { | |
| var accum = [], | |
| total, | |
| i; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function lazyAsync(f) { | |
| var args = [].slice.call(arguments).slice(1), | |
| listeners = [], | |
| captured; | |
| f.apply(null, [ | |
| function() { | |
| captured = [].slice.call(arguments); | |
| for(var i = 0, total = listeners.length; i < total; i++) { | |
| listeners[i].apply(null, captured); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Store = require('fantasy-stores'), | |
| target, | |
| store = Store( | |
| function(x) { return target = x; }, | |
| function() { return target; } | |
| ), | |
| newStore; | |
| store.set(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function* create() { | |
| for(var i = 0; i < 10; i++) { | |
| yield i; | |
| } | |
| } | |
| var gen = create(); | |
| console.log(gen.next()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Iter(machine) { | |
| this.gen = machine(); | |
| this.current = this.__iterator__(); | |
| } | |
| Iter.prototype.hasNext = function() { | |
| return this.current.hasNext(); | |
| }; | |
| Iter.prototype.next = function() { | |
| return this.current.next(); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var squishy = require('squishy-pants/bin/squishy-pants.min'), | |
| log = squishy.IO(squishy.constant( | |
| function(x) { | |
| console.log(x); | |
| } | |
| )), | |
| logger = squishy.curry( | |
| function(prefix, value) { | |
| log.ap(squishy.IO.of(prefix + ' > ' + value)).unsafePerform(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var time = function(milliseconds) { | |
| var value = milliseconds; | |
| return { | |
| concat: function(t) { | |
| return time(value + t.extract()); | |
| }, | |
| extract: function() { | |
| return value; | |
| }, | |
| map: function(f) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| macro $time { | |
| case {_ + $x:lit h $rest ... } => { | |
| return #{ .map(function(x) { return x + ($x * 1000 * 60 * 60) }) $time $rest ... } | |
| } | |
| case {_ + $x:lit m $rest ... } => { | |
| return #{ .map(function(x) { return x + ($x * 1000 * 60) }) $time $rest ... } | |
| } | |
| case {_ + $x:lit s $rest ... } => { | |
| return #{ .map(function(x) { return x + ($x * 1000) }) $time $rest ... } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| macro $string { | |
| case {_ ([$x $inner ...] $rest ...)} => { | |
| var ctx = #{$x}, | |
| value = ctx[0].token.value, | |
| str = makeValue(value, #{here}); | |
| return withSyntax($val = [str]) { | |
| return #{'[' + $val + $string($inner ...) + ']' + $string($rest ...)} | |
| } | |
| } |