diff options
author | Camil Staps | 2015-07-03 13:49:53 +0200 |
---|---|---|
committer | Camil Staps | 2015-07-03 13:49:53 +0200 |
commit | 132b9b61ec36ff4ee2a16d7f42d7994850dc2de1 (patch) | |
tree | f9acf0c1c18f2213cd41f2a837b5ea1634bc34bd /Logic.icl | |
parent | Cleanup (diff) |
Cleanup; simple truthtable; license; readme
Diffstat (limited to 'Logic.icl')
-rw-r--r-- | Logic.icl | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -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} |