Skip to content

Instantly share code, notes, and snippets.

@bhelyer
Created December 2, 2010 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhelyer/724508 to your computer and use it in GitHub Desktop.
Save bhelyer/724508 to your computer and use it in GitHub Desktop.
import std.math;
T[] map(T, V)(T function(T) f, V[] list)
{
T[] result = new T[](list.length);
foreach(k, v; list)
{
result[k] = f(v);
}
return result;
}
void main()
{
assert (map!(real, float) (&sqrt, [4.0f, 9.0f]) == [2.0f, 3.0f]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment