Skip to content

Instantly share code, notes, and snippets.

@devboy
Created November 22, 2011 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save devboy/1384637 to your computer and use it in GitHub Desktop.
Save devboy/1384637 to your computer and use it in GitHub Desktop.
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