Commit 0bc972dc authored by AVANZINI Martin's avatar AVANZINI Martin
Browse files

pretty printer bool expressions

parent af1a19bf
def start():
var sPrice, minPrice, tick_z, numShares
tick_z = 0
var sPrice, minPrice, numShares
while 0<=minPrice and minPrice<sPrice:
prob(1,3):
......@@ -11,5 +9,4 @@ def start():
numShares = unif(0,20)
while numShares>0:
numShares=numShares-1
tick_z=tick_z+sPrice
tick(tick_z)
tick(sPrice)
def qn ():
var l1, l2, n, i, tick_z
l1 = 0
l2 = 0
i = 0
while i <= n:
n = n - 1
if l1 > 0:
l1 = l1 - 1
if l2 > 0:
l2 = l2 - 1
prob (1,49):
prob(1,4):
l1 = l1 + 3
else:
prob(1,1):
l2 = l2 + 2
else:
l1 = l1 + 2
l2 = l2 + 1
if l1 >= l2:
tick_z = l1 + tick_z
else:
tick_z = l2 + tick_z
def qn ():
var l1, l2, n, i, tick_z
l1 = 0
l2 = 0
i = 0
while i <= n:
n = n - 1
if l1 > 0:
l1 = l1 - 1
if l2 > 0:
l2 = l2 - 1
prob (1,49):
prob(1,4):
l1 = l1 + 3
else:
prob(1,1):
l2 = l2 + 2
else:
l1 = l1 + 2
l2 = l2 + 1
if l1 >= l2:
tick_z = l1 + tick_z
else:
tick_z = l2 + tick_z
This diff is collapsed.
......@@ -147,10 +147,10 @@ variables g = S.unions [ E.variables a `S.union` E.variables b | (a :>=: b) <-
instance PP.Pretty p => PP.Pretty (Literal p) where
pretty (e1 :>=: e2) =
PP.nest 2 (PP.group (PP.pretty e1 PP.<$> PP.nest 2 (PP.group (PP.text "≥" PP.<$> PP.pretty e2))))
PP.group (PP.pretty e1) PP.</> PP.text "≥" PP.<+> PP.group (PP.pretty e2)
instance PP.Pretty l => PP.Pretty (DNF l) where
pretty Top = PP.text "⊤"
pretty Bot = PP.text "⊥"
pretty dnf = lst " ∨ " [ lst " ∧ " [ PP.group (PP.pretty l) | l <- lits c] | c <- conjs dnf]
where lst s = PP.hcat . PP.punctuate (PP.text s)
where lst s = PP.fillSep . PP.punctuate (PP.text s)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment