Skip to content

Instantly share code, notes, and snippets.

@dsp
Created January 23, 2015 18:46
Show Gist options
  • Save dsp/9004385965d248bd4631 to your computer and use it in GitHub Desktop.
Save dsp/9004385965d248bd4631 to your computer and use it in GitHub Desktop.
T[] filter(alias fun, T)(T[] tofilter) {
auto result = [];
foreach (auto e; tofilter) {
if (fun(e)) {
result ~= e;
}
}
return result;
}
auto even = [1,2,3,4].filter!(x => x % 2 == 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment