Skip to content

Commit 3a51c46

Browse files
authored
Merge pull request #17 from ryukinix/valid-operators
Add valid operators to webapp and add aliases
2 parents 41cde4f + b76bb0e commit 3a51c46

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

src/operators.lisp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
(eval-when (:compile-toplevel)
88
(defconstant F nil))
99

10-
(defparameter *valid-operators* '(~ ^ <=> => v [+]))
10+
(defparameter *valid-operators* '(~ ^ <=> => -> <-> v [+]))
1111

1212
;; operators
1313
(defun ~ (p)
@@ -23,13 +23,21 @@
2323
(or p q))
2424

2525
(defun => (p q)
26-
"Implication binary operator"
26+
"Conditional binary operator"
2727
(v (~ p) q))
2828

2929
(defun <=> (p q)
3030
"Biconditional binary operator"
3131
(^ (=> p q) (=> q p)))
3232

33+
(defun -> (p q)
34+
"Notation alias for conditional"
35+
(=> p q))
36+
37+
(defun <-> (p q)
38+
"Notation alias for biconditional"
39+
(<=> p q))
40+
3341
(defun [+] (p q)
3442
"XOR operator or exclusive disjunction operator"
3543
(^ (~ (^ p q))

src/package.lisp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@
4747
#:truth
4848
#:truth-infix
4949
#:*output-stream*
50+
#:*valid-operators*
5051
#:main)
5152
(:nicknames "INFERENCE"))

web/webapp.lisp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,15 @@
7878
:placeholder (trim-paren (prop table)))
7979
(:input :type "submit"
8080
:value "Eval"))
81-
(:pre (truth table))))
81+
(:pre (truth table))
82+
(:pre (format nil "Operators: ~a" inference:*valid-operators*))
83+
(:p "Some notes: "
84+
(:ul
85+
(loop for note in '("My lexer doesn't works very well for parenthesis."
86+
"Please, don't be evil. Use less than 10 variables."
87+
"Yes, [+] it's a XOR. Mathematically: p ⊕ q."
88+
"(=> ->) and (<=> <->) are aliases.")
89+
do (:li (render note)))))))
8290

8391
(defmethod render ((string string))
8492
(with-html

0 commit comments

Comments
 (0)