Last active
January 4, 2016 08:49
-
-
Save yjiro0403/784389cc679a3c23fc14 to your computer and use it in GitHub Desktop.
[D言語]UFCSを自分なりにメモ ref: http://qiita.com/yjiro0403/items/74b6eaf4c6cc2e4c2af1
This file contains hidden or 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
//'a'をn回繰り返した配列を作る | |
char[] str = 'a'.repeat(n).array; |
This file contains hidden or 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.file, std.string, std.algorithm, std.array; | |
//チェインメソッドを使わない処理 | |
string[] text = splitLines(readText("text.txt")); | |
string[] hoge; | |
foreach(int i; text){ | |
hoge[i] = text[i]; | |
} | |
//最初にデータをすべて読み込んで一気に分割する方法 | |
//対象ファイルが大きいと結構メモリを食うらしい | |
string[] text2 = splitLines(readText("text.txt")).map!strip.array; | |
//各行を順々に処理 | |
auto strippedLines = File("text.txt").byLineCopy().map!strip.array; |
This file contains hidden or 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.string, std.algorithm, std.array, std.conv; | |
//任意の要素をint型に変換して格納 | |
//入力するときはスペースで区切る | |
//もっといいやり方あるよね... | |
string[] input = readln().split; | |
int num = input[0].to!int; | |
//intの配列に代入 | |
int[] a = readln().split.map!(to!int).array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment