開発環境
- OS X El Capitan - Apple (OS)
- Emacs (Text Editor)
- Elm (プログラミング言語)
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 (Hard)(No. 3043).を取り組んでみる。
Do (Hard)(No. 3043)
入出力結果(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> -------------------------------------------------------------------------------- > personRecords = [{name="elm1", age=Just 16, address={country="Japan", state="Tokyo"}}, {name="elm2", age=Just 15, address={country="Japan", state="Tokyo"}}, {name="elm3", age=Just 17, address={country="Japan", state="Tokyo"}}, {name="elm4", age=Nothing, address={country="Japan", state="Tokyo"}}, {name="elm5", age=Just 10, address={country="Japan", state="Tokyo"}}] [{ name = "elm1", age = Just 16, address = { country = "Japan", state = "Tokyo" } },{ name = "elm2", age = Just 15, address = { country = "Japan", state = "Tokyo" } },{ name = "elm3", age = Just 17, address = { country = "Japan", state = "Tokyo" } },{ name = "elm4", age = Nothing, address = { country = "Japan", state = "Tokyo" } },{ name = "elm5", age = Just 10, address = { country = "Japan", state = "Tokyo" } }] : List { address : { country : String, state : String } , age : Maybe.Maybe number , name : String } > List.filter (\x -> case x.age of \ | Nothing -> False \ | Just a -> a > 16) personRecords [{ name = "elm3", age = Just 17, address = { country = "Japan", state = "Tokyo" } }] : List { address : { country : String, state : String } , name : String , age : Maybe.Maybe number } > :exit $
0 コメント:
コメントを投稿