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
本文介绍了Elm编程语言的基础概念,包括类型系统、代数数据类型、记录使用、函数定义及模式匹配等内容,并探讨了信号的概念及其在游戏开发中的应用。
119

被折叠的 条评论
为什么被折叠?



