aboutsummaryrefslogtreecommitdiff
path: root/Logic.icl
diff options
context:
space:
mode:
authorCamil Staps2015-07-03 13:49:53 +0200
committerCamil Staps2015-07-03 13:49:53 +0200
commit132b9b61ec36ff4ee2a16d7f42d7994850dc2de1 (patch)
treef9acf0c1c18f2213cd41f2a837b5ea1634bc34bd /Logic.icl
parentCleanup (diff)
Cleanup; simple truthtable; license; readme
Diffstat (limited to 'Logic.icl')
-rw-r--r--Logic.icl28
1 files changed, 27 insertions, 1 deletions
diff --git a/Logic.icl b/Logic.icl
index fbaba12..2c9cfde 100644
--- a/Logic.icl
+++ b/Logic.icl
@@ -1,3 +1,26 @@
+/**
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2015 Camil Staps
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
implementation module Logic
import StdEnv, StringUtils
@@ -90,7 +113,7 @@ where
line_b = "-"
line_e = "-\n"
line_s = "-+-"
- padlens = map ((max 5) o strlen o toString) exprs
+ padlens = map ((max 5) o strlen o toString) exprs // 5 is the length of False
toStringOrEmpty :: [Bool] -> String
toStringOrEmpty [] = ""
toStringOrEmpty [b:bs] = toString b
@@ -231,6 +254,9 @@ subexprs (App2 e1 op e2) = removeDup (subexprs e1 ++ subexprs e2 ++ [e1,e2])
sorted_subexprs :: (Expr -> [Expr])
sorted_subexprs = sort o subexprs
+simple_truthtable :: Expr -> TruthTable
+simple_truthtable e = {exprs = [Atom a \\ a <- all_atoms e] ++ [e], options = all_atom_options e}
+
truthtable :: Expr -> TruthTable
truthtable e = {exprs = sorted_subexprs e ++ [e], options = all_atom_options e}