Created
April 6, 2016 00:10
-
-
Save chuck0523/35a6ce778af8c49457a0df837d20f579 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Graphics.Element exposing (show) | |
import Graphics.Collage exposing (collage, filled, move, ngon) | |
import Color exposing (green, purple) | |
-- function(http://elm-lang.org/examples/functions) | |
four = | |
sqrt 16 | |
eleven = | |
max 2 11 | |
twenty = | |
max (sqrt 100) (4 * 5) | |
-- main = | |
-- show [four, eleven, twenty] -- [4,11,20] | |
-- infix(http://elm-lang.org/examples/infix) | |
five = | |
2 + 3 | |
sixteen = | |
8 * 2 | |
ten = | |
(4 * 3) - 2 | |
thirteen = | |
4 * 3 + 1 | |
isTeenage age = | |
(age > 12) && (age < 20) | |
isTeenage' age = | |
age > 12 && age < 20 | |
-- main = | |
-- show | |
-- [ isTeenage four | |
-- , isTeenage sixteen | |
-- , isTeenage eleven | |
-- , isTeenage thirteen | |
-- ] -- [False,True,False,True] | |
-- use fewer parens(http://elm-lang.org/examples/forward-apply) | |
-- main = | |
-- collage 200 200 [purplePentagon, greenPentagon] | |
purplePentagon = | |
move (20, 20) (filled purple (ngon 5 50)) | |
greenPentagon = | |
ngon 5 50 | |
|> filled green | |
|> move (-20, -20) | |
-- define function(http://elm-lang.org/examples/define-functions) | |
add x y = | |
x + y | |
factorial n = | |
List.product [1..n] | |
-- main = | |
-- show (add 1 (factorial 4)) -- 25 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment