2009-04-21から1日間の記事一覧
import std.range, std.stdio; struct R { int opIndex(int n){ return 0;//dummy } } void main() { R r; auto e = r[0]; writeln(isRandomAccessRange!(R)); //false? } あれー? こうじゃないのかな. つーか,標準ライブラリが1つもRangeを提供してくれ…
D言語のライブラリの中でも一際変態な輝いているアルゴリズム群がRangeの概念をサポートした. http://www.digitalmars.com/d/2.0/phobos/std_algorithm.html 配列以外のRangeには何があるのかな? おさらい count int[] arr = [ 1, 2, 4, 3, 2, 5, 3, 2, 4 …
import std.stdio : writeln; import std.random : Mt19937; import std.algorithm : advance; import std.range : front, popFront; void main() { { int[] arr = [5,4,3,2,1]; writeln(arr.front);//5 arr.popFront; writeln(arr.front);//4 arr.popFront;…
名作が名作のまま終わった. ジャンプに奇跡が起こった.