Add all the A tasks

This commit is contained in:
Ingy döt Net 2013-04-10 14:58:50 -07:00
parent 2dd7375f96
commit 051504d65b
1608 changed files with 18584 additions and 0 deletions

View file

@ -0,0 +1,7 @@
function map(a, func) {
for (var i in a)
a[i] = func(a[i]);
}
var a = [1, 2, 3, 4, 5];
map(a, function(v) { return v * v; });

View file

@ -0,0 +1 @@
var a = (1).to(10).collect(Math.pow.curry(undefined,2));

View file

@ -0,0 +1,15 @@
function cube(num) {
return Math.pow(num, 3);
}
var numbers = [1, 2, 3, 4, 5];
// get results of calling cube on every element
var cubes1 = numbers.map(cube);
// display each result in a separate dialog
cubes1.forEach(alert);
// array comprehension
var cubes2 = [cube(n) for each (n in numbers)];
var cubes3 = [n * n * n for each (n in numbers)];

View file

@ -0,0 +1 @@
Functional.map('x*x*x', [1,2,3,4,5])