Skip to content

Instantly share code, notes, and snippets.

@tbrosman
Created July 29, 2014 05:56
Show Gist options
  • Save tbrosman/9e683161ed00b6fba5aa to your computer and use it in GitHub Desktop.
Save tbrosman/9e683161ed00b6fba5aa to your computer and use it in GitHub Desktop.
scalar functors for math structures
static function genericApply<T>(shape:T, count:Int, getter:T->Int->Float, setter:T->Int->Float->Float, f:Float->Float)
{
for (i in 0...count)
{
setter(shape, i, f(getter(shape, i)));
}
}
genericApply(v, 2, Vector2.getArrayElement, Vector2.setArrayElement, Math.floor);
@tbrosman
Copy link
Author

T->Int->(T->Int->Float)->(T->Int->Float->Float)->(Float->Float)->Void

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment