Elm
- Day 1
- > [1, "2"] //強類型,要求數組内元素必須是同一個類型?
- Building Algebraic Data Types:> type Color = Black | White //Haskell文法?
- type List = Nil | Cons Int List
- type List a = Empty | Cons a (List a)
- Using Records
- > blackQueen = {color=Black, piece=Queen}
- > .color blackQueen //這是學習的Clojure?
- 函數
- > add x y = x + y
- > anonymousInc = \x -> x + 1
- > 5 |> anonymousInc |> double //這是學習的Elixir?
- > double <| anonymousInc <| 5
- 模式比對
- 簡化函數定義:> first (head::tail) = head
- Day 2
- 信号:A signal represents I/O as a value that varies over time(stream?Rx Observable?)
- main = Signal.map show Mouse.position
- count signal = Signal.foldp (\_ n -> n + 1) 0 signal
- 組合信号
- clickPosition = Signal.sampleOn Mouse.clicks Mouse.position //當clicks更新時采樣position
- 信号:A signal represents I/O as a value that varies over time(stream?Rx Observable?)
- Day 3
- games/skeleton.elm
- delta = inSeconds <~ fps n
- input = sampleOn delta (...)
- main = map display gameState
- gameState = foldp stepGame initialGameState input
- 略
- games/skeleton.elm