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
0d4b813c
Commit
0d4b813c
authored
Jul 13, 2016
by
zlu
🤸🏿
Browse files
Roll dice gives random integer
parent
d30cb31f
Changes
1
Hide whitespace changes
Inline
Side-by-side
random-number.elm
View file @
0d4b813c
import
Html
exposing
(
..
)
import
Html
.
Events
exposing
(
onClick
)
import
Html
.
App
as
App
import
Random
main
=
App
.
program
...
...
@@ -11,7 +12,7 @@ main =
}
type
alias
Model
=
{
dieFace
:
Int
}
type
Msg
=
Roll
type
Msg
=
Roll
|
NewFace
Int
init
:
(
Model
,
Cmd
Msg
)
init
=
...
...
@@ -21,7 +22,9 @@ update : Msg -> Model -> (Model, Cmd Msg)
update
msg
model
=
case
msg
of
Roll
->
(
model
,
Cmd
.
none
)
(
model
,
Random
.
generate
NewFace
(
Random
.
int
1
6
))
NewFace
newFace
->
(
Model
newFace
,
Cmd
.
none
)
view
:
Model
->
Html
Msg
view
model
=
...
...
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