Skip to content

Instantly share code, notes, and snippets.

@alphaKAI
Created March 8, 2015 02:33
Show Gist options
  • Select an option

  • Save alphaKAI/3f8df9dddb96bb804573 to your computer and use it in GitHub Desktop.

Select an option

Save alphaKAI/3f8df9dddb96bb804573 to your computer and use it in GitHub Desktop.
グローバルなラムダでメタプログラミング的なものをやってみた図
import std.stdio,
std.array,
std.range;
auto x = (int[] arr) pure nothrow @nogc @safe { return ++arr[0] * 2; };
int[] fx(int[] xss){ return xss.length ? x(xss) ~ fx(xss[1..$]) : xss; }
void main(){
writeln(fx(100.iota.array));
x = (int[] arr) pure nothrow @nogc @safe { return ++arr[0] * 3; };
writeln(fx(100.iota.array));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment