Skip to content

Instantly share code, notes, and snippets.

@be5invis
Created March 24, 2012 09:03
Show Gist options
  • Save be5invis/2180426 to your computer and use it in GitHub Desktop.
Save be5invis/2180426 to your computer and use it in GitHub Desktop.
Enumerator comprehension monad
-- Enumerator comprehension monad
var ecSchemata = [yield: fYield, return: fReturn, bind: fBind]
where
fReturn = Enumerable function(x):
if(x != undefined)
enumeration.yield! x
fYield(x) = x
fBind = Enumerable function(list, callback):
for(var x in list)
for(var y in callback x)
enumeration.yield! y
var table(G) =
var f = G.build ecSchemata
f.apply(this, arguments)()
var t = table =>
var x <- (1...9)
var y <- (1...9)
if(x <= y)
x + ' * ' + y + ' = ' + x * y
for(var item in t) trace item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment