aboutsummaryrefslogtreecommitdiff
path: root/Logic.icl
diff options
context:
space:
mode:
authorCamil Staps2015-07-04 19:53:55 +0200
committerCamil Staps2015-07-04 19:53:55 +0200
commitaf7f0d6b8103dbfa46b8d159be9c70e8db51e810 (patch)
treee347b06254819f2ba7c6c70adbcb9ed27aab4dbe /Logic.icl
parentReadme (diff)
Fix show for expressions (parentheses); allow parentheses in input
Diffstat (limited to 'Logic.icl')
-rw-r--r--Logic.icl11
1 files changed, 10 insertions, 1 deletions
diff --git a/Logic.icl b/Logic.icl
index 97d8df5..c678248 100644
--- a/Logic.icl
+++ b/Logic.icl
@@ -117,7 +117,16 @@ where
show opt (B b) = show opt b
show opt (Atom a) = show opt a
show opt (App1 op e) = show opt op +++ show opt e
- show opt (App2 e1 op e2) = show opt e1 +++ " " +++ show opt op +++ " " +++ show opt e2
+ show opt (App2 e1 op e2) = if needs_l "(" "" +++
+ show opt e1 +++
+ if needs_l ")" "" +++
+ " " +++ show opt op +++ " " +++
+ if needs_r "(" "" +++
+ show opt e2 +++
+ if needs_r ")" ""
+ where
+ needs_l = needs_parentheses_left (App2 e1 op e2)
+ needs_r = needs_parentheses_right (App2 e1 op e2)
instance == Op1
where