Created
October 11, 2010 08:25
-
-
Save rjungemann/620207 to your computer and use it in GitHub Desktop.
A JS port of the Ruby-version of the To Mock a Mockingbird birds
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
/* | |
Inspired by http://github.com/iande/code_bucket/raw/d6a29da107e7347612aa24803e4ee32cd4395220/birds/combinators.rb | |
*/ | |
var birds = { | |
"blue": function(x, y, z) { return x(y(z)); }, | |
"cardinal": function(x, y, z) { return x(y)(z); }, | |
"dove": function(x, y, z, w) { return x(y)(z(w)); }, | |
"eagle": function(x, y, z, w, v) { return x(y)(z(w)(v)); }, | |
"finch": function(x, y, z) { return z(y)(x); }, | |
"goldfinch": function(x, y, z, w) { return x(w)(y(z)); }, | |
"humming": function(x, y, z) { return; x(y)(z)(y); }, | |
"identity": function(x) { return x; }, | |
"jay": function(x, y, z, w) { return x(y)(x(w)(z)); }, | |
"kestrel": function(x, y) { return x; }, | |
"lark": function(x, y) { return x(y(y)); }, | |
"mocking": function(x) { return x(x); }, | |
"owl": function(x, y) { return y(x(y)); }, | |
"queer": function(x, y, z) { return y(x(z)); }, | |
"quixotic": function(x, y, z) { return x(z(y)); }, | |
"quirky": function(x, y, z) { return z(x(y)); }, | |
"robin": function(x, y, z) { return y(z)(x); }, | |
"starling": function(x, y, z) { return x(z)(y(z)); }, | |
"thrush": function(x, y) { return y(x); }, | |
"turing": function(x, y) { return y(x(x)(y)); }, | |
"vireo": function(x, y, z) { return z(x)(y); }, | |
"warbler": function(x, y) { return x(y)(y); }, | |
"converseWarbler": function(x, y) { return y(x)(x); }, | |
} | |
birds.B = birds.blue; | |
birds.C = birds.cardinal; | |
birds.D = birds.dove; | |
birds.E = birds.eagle; | |
birds.F = birds.finch; | |
birds.G = birds.goldfinch; | |
birds.H = birds.humming; | |
birds.I = birds.identity; | |
birds.J = birds.jay; | |
birds.K = birds.kestrel; | |
birds.L = birds.lark; | |
birds.M = birds.mocking; | |
birds.O = birds.owl; | |
birds.Q = birds.queer; | |
birds.Q1 = birds.quixotic; | |
birds.Q2 = birds.quirky; | |
birds.R = birds.robin; | |
birds.S = birds.starling; | |
birds.T = birds.thrush; | |
birds.U = birds.turing; | |
birds.V = birds.vireo; | |
birds.W = birds.warbler; | |
birds.W1 = birds.converseWarbler; | |
birds.YU = birds.U(birds.U); | |
birds.YS = birds.S(birds.L)(birds.L); | |
birds.YB = birds.B(birds.M)(birds.L); | |
birds.YQ = birds.Q(birds.Q(birds.M))(birds.M); | |
birds.Y = birds.YS; | |
try { | |
module.exports = birds; | |
} catch(e) { | |
birds; | |
} |
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
birds = | |
blue: (x, y, z) -> x y(z) | |
cardinal: (x, y, z) -> x(y) z | |
dove: (x, y, z, w) -> x(y) z(w) | |
eagle: (x, y, z, w, v) -> x(y) z(w)(v) | |
finch: (x, y, z) -> z(y) x | |
goldfinch: (x, y, z, w) -> x(w) y(z) | |
humming: (x, y, z) -> x(y)(z)(y) | |
identity: (x) -> x | |
jay: (x, y, z, w) -> x(y) x(w)(z) | |
kestrel: (x, y) -> x | |
lark: (x, y) -> x y(y) | |
mocking: (x) -> x x | |
owl: (x, y) -> y x(y) | |
queer: (x, y, z) -> y x(z) | |
quixotic: (x, y, z) -> x z(y) | |
quirky: (x, y, z) -> z x(y) | |
robin: (x, y, z) -> y(z) x | |
starling: (x, y, z) -> x(z) y(z) | |
thrush: (x, y) -> y x | |
turing: (x, y) -> y x(x)(y) | |
vireo: (x, y, z) -> z(x) y | |
warbler: (x, y) -> x(y) y | |
converseWarbler: (x, y) -> y(x) x | |
birds.B = birds.blue | |
birds.C = birds.cardinal | |
birds.D = birds.dove | |
birds.E = birds.eagle | |
birds.F = birds.finch | |
birds.G = birds.goldfinch | |
birds.H = birds.humming | |
birds.I = birds.identity | |
birds.J = birds.jay | |
birds.K = birds.kestrel | |
birds.L = birds.lark | |
birds.M = birds.mocking | |
birds.O = birds.owl | |
birds.Q = birds.queer | |
birds.Q1 = birds.quixotic | |
birds.Q2 = birds.quirky | |
birds.R = birds.robin | |
birds.S = birds.starling | |
birds.T = birds.thrush | |
birds.U = birds.turing | |
birds.V = birds.vireo | |
birds.W = birds.warbler | |
birds.W1 = birds.converseWarbler | |
birds.YU = birds.U(birds.U) | |
birds.YS = birds.S(birds.L)(birds.L) | |
birds.YB = birds.B(birds.M)(birds.L) | |
birds.YQ = birds.Q(birds.Q(birds.M))(birds.M) | |
birds.Y = birds.YS | |
try | |
module.exports = birds | |
catch e | |
birds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment