Elm (programming language): Difference between revisions

Content deleted Content added
Add references section
Line 40:
Elm has a small but expressive set of language constructs, including if-expressions, let-expressions, case-expressions, anonymous functions, and list interpolation.
 
Elm also has both a module system and a foreign function interface for JavaScript.
<source lang="haskell">
-- if-expression
makePositive n = if n < 0 then 0-n else n
 
-- let-expressions
turing = let picture = fittedImage 200 200 "alan-turing.jpg" in
flow down [ plainText "Alan Turing", picture ]
 
-- case-expression
isEmpty list = case list of
{ [] -> True
; _ : _ -> False }
 
-- anonymous functions
keepEvens numbers = filter (\n -> n `mod` 2 == 0) numbers
 
-- list interpolation
factorial n = product [1..n]
</source>
 
Elm also has a module system and foreign function interface for JavaScript.
 
==References==