Aha. yes, I think this answers the second part of what I was after. Thank
you. I'm going dig a bit deeper with this.

On Mon, May 28, 2012 at 2:39 PM, Angel Java Lopez <[email protected]>wrote:

> And you can write
>
> function compose(f,g)
>  {
>  return function(x) { return f(g(x)); }
>  };
>
> compose(function(x) { return x*x; }, function(x) { return x*2; })(3);
>
> --> 36
>
> too
>
> lambda, the best thing since sliced bread ;-)
>
> On Mon, May 28, 2012 at 5:33 PM, Joshua Holbrook 
> <[email protected]>wrote:
>
>> First of all, these all look like named functions and not anonymous
>> functions. The difference is that anonymous functions don't have a
>> name in between the function keyword and the parens, basically. So,
>> nothing special.
>>
>> Are you trying to do something like:
>>
>>    var first = function () { return 'first'; },
>>        second = function () { return 'second'; };
>>
>>    function runFunctions (a, b) {
>>      console.log(a());
>>      console.log(b());
>>    }
>>
>>    runFunctions(first, second);
>>
>> this ?
>>
>> --Josh
>>
>> On Mon, May 28, 2012 at 11:07 AM, Joshua Bowles <[email protected]>
>> wrote:
>> > I'm clearly missing something about anonymous functions in node. As a
>> > learning exercise I'm trying to pass multiple lambdas to a function.
>> > I've got a gist https://gist.github.com/2820160  (and a comparison in
>> > Ruby of what I'm trying to do https://gist.github.com/2820073).
>> >
>> > Thanks in advance!
>> >
>> > I can do this in node:
>> >
>> > function executeThree(someFunction, value) {
>> >  someFunction(value);
>> > }
>> > executeThree(function(word) {console.log(word); }, "lambda_three");
>> >
>> >
>> > I'm not able to figure out how to pass multiple anonymous functions to
>> > a function such as this:
>> >
>> > function lambda_good( ) {
>> >  function executeOne(someFunction, someValue) {
>> >    someFunction(someValue);
>> >  }
>> >  function executeTwo(anotherFunction, anotherValue){
>> >    anotherFunction(anotherValue);
>> >  }
>> > }
>> >
>> >
>> > I've toyed with a lot of different definitions for lambda_good but I
>> > can't seem to get it to work. Can someone help me see what I'm missing
>> > here?
>> >
>> > SIDE NOTE: this is how I can do it Ruby;
>> >
>> > def func_one
>> >  func_one = lambda do
>> >    puts "lambda_one"
>> >  end
>> >  #func_one.call
>> > end
>> >
>> > def func_two
>> >  func_two = lambda do
>> >    puts "lambda_two"
>> >  end
>> >  #func_two.call
>> > end
>> >
>> > def lambda_good(func1,func2)
>> >  func1.call
>> >  func2.call
>> > end
>> >
>> > --
>> > Job Board: http://jobs.nodejs.org/
>> > Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> > You received this message because you are subscribed to the Google
>> > Groups "nodejs" group.
>> > To post to this group, send email to [email protected]
>> > To unsubscribe from this group, send email to
>> > [email protected]
>> > For more options, visit this group at
>> > http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>>
>>
>> --
>> Joshua Holbrook
>> Engineer
>> Nodejitsu Inc.
>> [email protected]
>>
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>
>  --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to