Skip to content

Commit

Permalink
array: Add forEach
Browse files Browse the repository at this point in the history
  • Loading branch information
j3k0 committed Oct 10, 2016
1 parent e268258 commit 6bdc06a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/fxp/utils/arrayUtils.as
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ package fxp.utils {

// mapEach :: Array[X -> Y] -> Array[X] -> Array[Y]
// TODO: test & document
array.mapEach = F.curry(function(func:Array, arr:*):Array {
array.mapEach = F.curry(function(func:Array, arr:Array):Array {
var ret:Array = [];
for (var i:int = 0, l:int = func.length; i < l; ++i)
ret.push(func[i](arr[i]));
Expand Down Expand Up @@ -186,11 +186,19 @@ package fxp.utils {

// forRange :: Int -> (Int -> _) -> _
// TODO: test & document
array.forRange = F.curry(function(max:int, func:Function):Array {
array.forRange = F.curry(function(max:int, func:Function):void {
for (var i:int = 0; i < max; ++i)
func(i);
});

// forRange :: Int -> (Int -> _) -> _
// TODO: test & document
array.forEach = F.curry(function(func:Function, arr:Array):Array {
for (var i:int = 0; i < arr.length; ++i)
func(arr[i]);
return arr;
});

// equals :: Array<T> -> Array<T> -> Boolean
// TODO: test & document
array.equals = F.curry(function(a:Array, b:Array):Boolean {
Expand Down

0 comments on commit 6bdc06a

Please sign in to comment.