Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save tiegz/373036 to your computer and use it in GitHub Desktop.

Select an option

Save tiegz/373036 to your computer and use it in GitHub Desktop.
var λ = function(k){var a=[];while(a.length+1<arguments.length){a.push(arguments[a.length+1])};return function(o){return((o[k]&&o[k]instanceof Function)?o[k].apply(this,a):o[k]);}};
var ary = [
{num:1, f:function(a,b,c){console.log("A: " + a + "," + b + "," + c);}},
{num:2, f:function(a,b,c){console.log("B: " + a + "," + b + "," + c);}},
{num:3, f:function(a,b,c){console.log("C: " + a + "," + b + "," + c);}}
];
ary.forEach(λ('f',1,2,3));
# => A: 1,2,3
# => B: 1,2,3
# => C: 1,2,3
ary.map(λ('num'));
# => [1, 2, 3]
@iamjwc

iamjwc commented Apr 20, 2010

Copy link
Copy Markdown

ary.map('num'.λ);

@tiegz

tiegz commented Apr 20, 2010

Copy link
Copy Markdown
Author

ary.map('num'.toFunction) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment