diff options
author | Camil Staps | 2018-01-07 09:28:53 +0100 |
---|---|---|
committer | Camil Staps | 2018-01-07 09:28:53 +0100 |
commit | 91da6e9464b1468532666096422fb1586c18bc51 (patch) | |
tree | 7380666b77322e990c34d9dadd6500cb22b1ac85 /assignment-13/uFPL.icl | |
parent | Simulator improvements; continue with countdown example (diff) |
Better infix priorities
Diffstat (limited to 'assignment-13/uFPL.icl')
-rw-r--r-- | assignment-13/uFPL.icl | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/assignment-13/uFPL.icl b/assignment-13/uFPL.icl index 234d2cd..4f15e55 100644 --- a/assignment-13/uFPL.icl +++ b/assignment-13/uFPL.icl @@ -281,11 +281,12 @@ example_score = "a" :=: pressed b0 >>> [scorea <# scorea +. lit 1] ||| "b" :=: pressed b1 >>> [scoreb <# scoreb +. lit 1] ||| "r" :=: pressed b2 >>> [scorea <# lit 0, scoreb <# lit 0] - ||| "print" :=: (Change scorea ?| Change scoreb) >>> + ||| "print" :=: (Change scorea ?| Change scoreb) >>> ( SetCursor (lit 0, lit 0) :. Print scorea :. Print (lit '-') :. Print scoreb + ) where scorea = rwInt "scorea" 0 scoreb = rwInt "scoreb" 0 @@ -301,14 +302,20 @@ example_countdown = Print (lit ':') :. Print seconds )]) :. - When (seconds ==. lit 0 &&. minutes >. lit 0) (seconds <# lit 60 :. minutes <# minutes -. lit 1) :. - When (seconds <. lit 0) [seconds <# lit 0] :. - When (minutes <. lit 0) [minutes <# lit 0] :. - When (seconds ==. lit 0 &&. minutes ==. lit 0) [running <# false] + seconds ?= lit 0 >>> ( + minutes <# minutes -. lit 1 :. + seconds <# lit 60 + ) :. + minutes ?= lit 0 >>> [ + running <# false + ] ||| "setsec" :=: pressed b0 >>> [seconds <# seconds +. lit 1] ||| "setmin" :=: pressed b1 >>> [minutes <# minutes +. lit 1] ||| "on_off" :=: pressed b2 >>> [running <# running ? (false, true)] - ||| "reset" :=: pressed b3 >>> [seconds <# lit 0, minutes <# lit 0] + ||| "reset" :=: pressed b3 >>> ( + seconds <# lit 0 :. + minutes <# lit 0 + ) where running = rwBool "running" False minutes = rwUInt "minutes" 0 |