Last active
August 29, 2015 14:06
-
-
Save sinkuu/92d3c438383f65f7e369 to your computer and use it in GitHub Desktop.
std.algorithm.cacheの使用例 http://qiita.com/giiko_/items/8c3442e8e7a83cc0b91a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.algorithm; | |
import std.random; | |
import std.range; | |
import std.stdio; | |
import std.string; | |
import std.typecons; | |
void main() | |
{ | |
immutable dic = [["今日","ぞい"],["も"],["1","ぞい"],["日","ぞい"],["がん","ぞい"],["ばる","ぞい"],["ぞい!"]]; | |
auto count = dic | |
.map!(w => w.randomSample(1).front).repeat.map!join | |
.cache | |
.tee!(writeln, No.pipeOnPop).until("今日も1日がんばるぞい!") | |
.walkLength + 1; | |
writefln("がんばるまで %s zoiでした", count); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment