Created
January 14, 2014 09:21
-
-
Save poochin/8415528 to your computer and use it in GitHub Desktop.
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 | |
: 関数A | |
; | |
値Aを関数Aの第一引数として呼び出す。 | |
----- | |
連続した関数呼び出し | |
値A | |
: 関数A | |
: 関数B | |
; | |
値Aで関数Aを呼び出し、関数Aの戻り値で関数Bを呼び出す。 | |
----- | |
関数の戻り値を変数に代入 | |
値A | |
: 関数A | |
=: 変数A; | |
代入はアウトデントした行に =: 変数名 とする。 | |
----- | |
複数の引数で関数を呼び出す | |
(値A, 値B) | |
*: 関数A | |
; | |
パイプ子(:)と展開指示子(*)を組み合わせて呼び出す | |
**/ | |
int pow (int i) { | |
return i * i; | |
} | |
int main() { | |
int[] list; | |
[1,2,3,4,5] | |
: expr (pow, _) // 受け取ったデフォルトの値を用いて tuple の生成 | |
*: map // 引数を展開して map に渡す | |
=: list; // 最後の戻り値を list に代入 | |
if (list.length >= 5) { | |
(filter, list) | |
*: map | |
: expr _.length | |
; | |
} | |
else { | |
list.length | |
; | |
} | |
=: i; // 各ブロックの最後の値を代入 | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment