actionscript 3 - When would it make sense to pass a function to a function? -


OK, so it is possible to pass the function to another function.

This is clearly very powerful, but another important question is, when it is wise to do this, because whenever you call any other function, there are performance overheads ?

A function that takes the function as its argument is called higher sequence function is called

  function (f, g) {return function (x) {return f (p) (return function)  

g (x)) ; }; } Function map (f, xs) {var ys = []; (Var i = 0; i & lt; xs.length; ++ i) ys.push (f (x [i])) for; Return ys; }

With that, you can change an array with two functions in one line:

  var a = ["one", "two" , " three "]; Var b = Map (composition (touppercase, reverse), A); // B. Now ["EoO", "OWT", "EERHT"]  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

jquery - SimpleModal Confirm fails to submit form -