-
-
Save rightfold/795f8a9708db23ac5b94 to your computer and use it in GitHub Desktop.
This file contains 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
» node src/main.js | tee /dev/stderr > out.js && python2.7 -c 'print "*" * 80' && node out.js | |
// import "underscore" as _; | |
// | |
// extern Function; | |
// extern Math; | |
// extern console; | |
// | |
// protocol Functor { | |
// def map(this, f); | |
// } | |
// | |
// implement Functor for Function { | |
// def map(f, g) = _.compose(f, g); | |
// } | |
// | |
// def square(x) = Math.pow(x, 2); | |
// def cube(x) = Math.pow(x, 3); | |
// | |
// def main() = { | |
// console.log(square(2)); | |
// console.log(cube(2)); | |
// console.log(map(square, cube)(2)); | |
// }; | |
require("/Users/rightfold/lasagnascript/lib/runtime"); | |
var $lasagnascript$module = module.exports; | |
var _ = require('underscore'); | |
$lasagnascript$module.Functor = $lasagnascript$protocol([{ | |
name: 'map', | |
id: 'map$dfe61404_8692_4a79_a3ce_f4e2dcc10cb3' | |
}]); | |
$lasagnascript$module.map = function () { | |
return arguments[0].map$dfe61404_8692_4a79_a3ce_f4e2dcc10cb3.apply(null, arguments); | |
}; | |
$lasagnascript$module.Functor.implement(Function, [{ | |
name: 'map', | |
implementation: function (f, g) { | |
return _.compose(f, g); | |
} | |
}]); | |
$lasagnascript$module.square = function (x) { | |
return Math.pow(x, 2); | |
}; | |
$lasagnascript$module.cube = function (x) { | |
return Math.pow(x, 3); | |
}; | |
$lasagnascript$module.main = function () { | |
return console.log($lasagnascript$module.square(2)), console.log($lasagnascript$module.cube(2)), console.log($lasagnascript$module.map($lasagnascript$module.square, $lasagnascript$module.cube)(2)); | |
}; | |
$lasagnascript$module.main(); | |
******************************************************************************** | |
4 | |
8 | |
64 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment