Content deleted Content added
No edit summary |
No edit summary |
||
Line 17:
Elm allows [http://en.wikipedia.org/wiki/Markdown Markdown] to be embedded directly, so users can create text content in a familiar and natural way.
== Syntax and Semantics ==
Elm's version of [http://en.wikipedia.org/wiki/Functional_reactive_programming Functional Reactive Programming] is event-driven, meaning that updates are only performed as necessary. It shares the closest resemblance to Event-Driven FRP and Arrowized FRP.
The following program displays the position of the mouse as it moves around the screen, automatically updating the screen in real-time.
Line 35:
factorial n = product [1..n]
</source>
Elm has a small but expressive set of language constructs, including if-expressions, let-expressions, case-expressions, and anonymous functions.
<source lang="haskell">
-- if-expression
makePositive n = if n < 0 then 0-n else n
-- let-expressions
keepEvens numbers =
let isEven n = n `mod` 2 == 0 in
filter isEven numbers
-- case-expression
keepEvens' numbers =
case numbers of
{ hd : tl -> if hd `mod` 2 == 0 then hd : keepEvens' tl else keepEvens' tl
; [] -> [] }
-- anonymous functions
keepEvens'' numbers = filter (\n -> n `mod` 2 == 0) numbers
</source>
== External links ==
|