Skip to content

Instantly share code, notes, and snippets.

View schmerg's full-sized avatar

Tim schmerg

View GitHub Profile
@schmerg
schmerg / def.js
Created June 1, 2012 17:39
Demo of a hacky def function for a lambda-like syntax in javascript
// def(function() { $[0]+$[1] }) --> $ is a real array of args, adds a return
var def = function(f) {
// Another option is like this so $0, $1 etc
//return eval("("
// +(f.toString()
// .replace(/\$_/g, "arguments[0]")
// .replace(/\$[\d+]/g, function(r,num) { return "arguments["+num+"]" })
// .replace(/\) { /, ") { return ")
// )+")");