Created
November 22, 2011 01:41
-
-
Save devboy/1384637 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ints = [1, 2, 3] | |
var strings = ["a", "bb", "ccc"]; | |
var biggerThan1 = function(x:Int) { | |
return x > 1; | |
} | |
var longerThan1 = function(x:String) { | |
return x.length > 1; | |
} | |
function array_delete_if<T>( array: Array<T>, processor: T-> Bool ):Array<T> | |
{ | |
for ( item in array ) | |
if ( processor(item) ) | |
array.remove( item ); | |
return array; | |
} | |
array_delete_if(ints, biggerThan1); // [ 1 ] | |
array_delete_if(strings, longerThan1); // [ "a" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment