Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Menu
Open sidebar
Ryan Frazier
elm-calculator
Compare Revisions
v0.5...v0.6
Commits (1)
Add negative number support
· e2765148
Ryan Frazier
authored
Oct 08, 2019
e2765148
Hide whitespace changes
Inline
Side-by-side
src/Main.elm
View file @
e2765148
...
...
@@ -76,6 +76,7 @@ type Msg
|
Back
|
Enter
|
SetDecimal
|
SetSign
update
:
Msg
->
Model
->
Model
...
...
@@ -88,6 +89,16 @@ update msg model =
else
{
model
|
currentNum
=
model
.
currentNum
++
"
."
}
SetSign
->
if
model
.
currentNum
==
"
0"
then
model
else
if
String
.
startsWith
"
-"
model
.
currentNum
then
{
model
|
currentNum
=
String
.
dropLeft
1
model
.
currentNum
}
else
{
model
|
currentNum
=
"
-"
++
model
.
currentNum
}
ClearAll
->
initialModel
...
...
@@ -229,7 +240,8 @@ section =
,
cell
(
onClick
<|
InputOperator
Add
)
Single
Yellow
"
+"
,
cell
(
onClick
<|
InputNumber
0
)
Single
White
"
0"
,
cell
(
onClick
SetDecimal
)
Single
White
"
."
,
cell
(
onClick
<|
Enter
)
Double
Yellow
"
Enter"
,
cell
(
onClick
SetSign
)
Single
White
"
+/-"
,
cell
(
onClick
<|
Enter
)
Single
Yellow
"
Enter"
]
...
...