関数
Elmは関数を主体にプログラムを記述していくので重要です。関数の種類は以下の二種類があります。
無名関数(anonymous functions)
名前付き関数(named functions)
無名関数
code:AnonymousFunc.elm
-- (\args -> body)
(\x -> x / 2)
<function> : Float -> Float
(\x -> x / 2) 128
64 : Float
-- (\arg1 arg2 -> body)
(\x y -> x / y)
<function> : Float -> Float -> Float
(\x y -> x / y) 128 2
64 : Float
名前付き関数
code:NamedFunc.elm
half x = x / 2
<function> : Float -> Float
half 128
64 : Float
half = (x -> x / 2)
half 128
64 : Float
型アノテーション(Type Annotations), シグネチャ(function signatures)
参考
コメント
パワー使うな、徐々に更新していきまする・・・/ababup1192/ababup1192.icon