summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assignment-13/uFPL.dcl4
-rw-r--r--assignment-13/uFPL.icl19
2 files changed, 15 insertions, 8 deletions
diff --git a/assignment-13/uFPL.dcl b/assignment-13/uFPL.dcl
index f9b3ed6..fee3c26 100644
--- a/assignment-13/uFPL.dcl
+++ b/assignment-13/uFPL.dcl
@@ -82,11 +82,11 @@ pressed :: (Expr Bool RO) -> Trigger
| E.rwa rwb: SetCursor (Expr Int rwa, Expr Int rwb)
| E.t rw: Print (Expr t rw) & Expr, toString t
-:: NamedRule = E.r: (:=:) infix 1 String r & gen r CBody & run, allShares, TC r
+:: NamedRule = E.r: (:=:) infixr 1 String r & gen r CBody & run, allShares, TC r
class gen f t :: f -> t
-class (:.) infixr 3 r :: Rule r -> [Rule]
+class (:.) infixr 1 r :: Rule r -> [Rule]
instance :. Rule
instance :. [Rule]
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