Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
zlu
zlu.me
Commits
a6025cdc
Commit
a6025cdc
authored
Jul 15, 2016
by
zlu
🤸🏿
Browse files
Roll to decide lunch spot
parent
4f847a69
Changes
1
Hide whitespace changes
Inline
Side-by-side
random-number.elm
View file @
a6025cdc
...
...
@@ -2,6 +2,7 @@ import Html exposing (..)
import
Html
.
Events
exposing
(
onClick
)
import
Html
.
App
as
App
import
Random
import
Array
main
=
App
.
program
...
...
@@ -22,17 +23,25 @@ update : Msg -> Model -> (Model, Cmd Msg)
update
msg
model
=
case
msg
of
Roll
->
(
model
,
Random
.
generate
NewFace
(
Random
.
int
1
6
))
(
model
,
Random
.
generate
NewFace
(
Random
.
int
0
5
))
NewFace
newFace
->
(
Model
newFace
,
Cmd
.
none
)
view
:
Model
->
Html
Msg
view
model
=
div
[]
[
h1
[]
[
Html
.
text
(
toString
model
.
dieFace
)
]
[
h1
[]
[
Html
.
text
(
Maybe
.
withDefault
"
Cannot decide, roll again"
(
Array
.
get
model
.
dieFace
choices
)
)
]
,
button
[
onClick
Roll
]
[
Html
.
text
"
Roll"
]
]
subscriptions
:
Model
->
Sub
Msg
subscriptions
model
=
Sub
.
none
choices
=
Array
.
fromList
[
"
Ceara"
,
"
Burger Bros"
,
"
Boamesa"
,
"
Vila Lobos"
,
"
Graveyard Hotdogs"
,
"
Try again"
]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment