Does ActionScript3 provide a list of concepts or lambda calculus?
I am porting some code that I prototyped in python to execute flash, and while ActionScript doesn't suck as bad as I expected (I hear v3 is much better than v2!) There is also something else that I have to make this seem overly prosaic / formulaic, like summing a list ...
var a:int = 0;
for each ( var value:int in annual_saving )
{
a = a + value;
}
return a / 100;
Unlike...
return reduce(lambda x,y: (x+y), self.annual_saving ) / 100
It looks a bit like Java for me (ewe Java: puke! XO ###)
Am I just not aware of the cool3 class summing function? Or does he understand lambda calculus or does he understand a list? or provide some other such short notation? Am I right in suspecting there is a more elegant way to do this, or am I stuck in the 20th century for the remainder of this project !?
Cheers :)
Roger.
source to share
ActionScript is very similar to JS. You could easily implement it yourself if you had to:
var annual_saving = [50, 100, 50, 100];
function reduce (f, arr) {
var a = arr[0];
for (var i = 1; i < arr.length; i++) {
a = f(a,arr[i]);
}
return a;
}
var res = reduce(function (x,y) { return x+y }, annual_saving);
You can easily extend this ... the syntax will be somewhat less attractive, but still very concise.
source to share