Thanks again Angel and Joshua for clarifying soem concepts. For
completeness sake of this thread here is what I was trying to clarify for
myself; the complete gist is here: (https://gist.github.com/2820160).
-------------------------------------------------------------------------

var func_one = function(someFunction, someValue){someFunction(someValue);},
  func_two = function(anotherFunction,
anotherValue){anotherFunction(anotherValue);};

function say(word) {console.log(word);}
function speak(anotherWord) {console.log(anotherWord);}

function runFunctionsTwo(a,b) {
  return a + b;
}

runFunctionsTwo(func_one(say,'hello'),func_two(speak,'world'));


On Mon, May 28, 2012 at 3:08 PM, Joshua Bowles <bowlesl...@gmail.com> wrote:

> 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 
> <ajlopez2...@gmail.com>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 <josh.holbr...@gmail.com
>> > 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 <bowlesl...@gmail.com>
>>> 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 nodejs@googlegroups.com
>>> > To unsubscribe from this group, send email to
>>> > nodejs+unsubscr...@googlegroups.com
>>> > For more options, visit this group at
>>> > http://groups.google.com/group/nodejs?hl=en?hl=en
>>>
>>>
>>>
>>> --
>>> Joshua Holbrook
>>> Engineer
>>> Nodejitsu Inc.
>>> j...@nodejitsu.com
>>>
>>> --
>>> 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 nodejs@googlegroups.com
>>> To unsubscribe from this group, send email to
>>> nodejs+unsubscr...@googlegroups.com
>>> 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 nodejs@googlegroups.com
>> To unsubscribe from this group, send email to
>> nodejs+unsubscr...@googlegroups.com
>> 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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to