2016年4月21日木曜日

開発環境

Seven More Languages in Seven Weeks (Bruce Tate (著)、Ian Dees (著)、Frederic Daoud (著)、Jack Moffitt (著)、Pragmatic Bookshelf)のChapter 3(Elm)、Day 1(Handling the Basics)、Do (Medium)(No. 3034).を取り組んでみる。

Do (Medium)(No. 3034)

入出力結果(Emacs, Terminal, elm repl)

$ elm-repl
---- elm repl 0.16.0 -----------------------------------------------------------
 :help for help, :exit to exit, more at <https://github.com/elm-lang/elm-repl>
--------------------------------------------------------------------------------
> multiply a b = a * b
<function> : number -> number -> number
> multiply 6 8
48 : number
> multiplyX = multiply 6
<function> : number -> number
> multiplyX 8
48 : number
> multiplyXY = multiplyX 8
48 : number
> multiplyXY
48 : number
> List.filter
<function> : (a -> Bool) -> List a -> List a
> personRecords = [{name="elm1", age=16, address={country="Japan", state="Tokyo"}}, {name="elm2", age=15, address={country="Japan", state="Tokyo"}},  {name="elm3", age=17, address={country="Japan", state="Tokyo"}}, {name="elm4", age=18, address={country="Japan", state="Tokyo"}}, {name="elm5", age=10, address={country="Japan", state="Tokyo"}}]
[{ name = "elm1", age = 16, address = { country = "Japan", state = "Tokyo" } },{ name = "elm2", age = 15, address = { country = "Japan", state = "Tokyo" } },{ name = "elm3", age = 17, address = { country = "Japan", state = "Tokyo" } },{ name = "elm4", age = 18, address = { country = "Japan", state = "Tokyo" } },{ name = "elm5", age = 10, address = { country = "Japan", state = "Tokyo" } }]
    : List
        { address : { country : String, state : String }
        , age : number
        , name : String
        }
> List.filter (\x -> x.age > 16) personRecords
[{ name = "elm3", age = 17, address = { country = "Japan", state = "Tokyo" } },{ name = "elm4", age = 18, address = { country = "Japan", state = "Tokyo" } }]
    : List
        { address : { country : String, state : String }
        , name : String
        , age : number
        }
> :exit
$

0 コメント:

コメントを投稿