Skip to content

Commit 41cde4f

Browse files
authored
Merge pull request #16 from ryukinix/hotfixes
Hotfixes after the new release
2 parents efc40e9 + 607573e commit 41cde4f

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

src/truth-table.lisp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
(defparameter *truth-string* "T")
77
(defparameter *false-string* "F")
8-
(defparameter *output-stream* *standard-output*
8+
(defparameter *output-stream* nil
99
"Default stream to write the results")
1010

1111
(defun propositionp (symbol)
@@ -211,10 +211,11 @@ a tautology."
211211

212212
(defun main ()
213213
(format t "Example of usage: (p ^ q)~%Operators: ~a ~%" *valid-operators*)
214-
(handler-case (loop do (princ "TRUTH-TABLE> ")
215-
do (force-output)
216-
do (print-truth-table (infix-to-prefix (read))))
217-
(end-of-file () )
218-
#+sbcl (sb-sys:interactive-interrupt () nil))
219-
220-
(format t "~%Goodbye!~%"))
214+
(let ((*output-stream* *standard-output*))
215+
(handler-case (loop do (princ-n "TRUTH-TABLE> ")
216+
do (force-output *output-stream*)
217+
do (print-truth-table (infix-to-prefix (read))))
218+
(end-of-file () )
219+
#+sbcl (sb-sys:interactive-interrupt () nil))
220+
221+
(format t "~%Goodbye!~%")))

web/webapp.lisp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
#:defapp)
1313
(:export #:start
1414
#:stop
15-
#:*propostion*
15+
#:*proposition*
1616
#:*port*)
1717
(:nicknames #:webapp))
1818

1919
(in-package lisp-inference/web)
2020

21-
(defvar *proposition* '(P => Q) "Default proposition")
21+
(defvar *proposition* "P => Q" "Default proposition")
2222
(defvar *port* (find-port:find-port))
2323

2424
(defapp truth-table
@@ -34,6 +34,15 @@
3434
:initform nil
3535
:accessor truth)))
3636

37+
(defun parse-string (string)
38+
"Translate string to a list expression"
39+
(mapcar (lambda (x)
40+
(intern (string-upcase x) :lisp-inference))
41+
(str:words string)))
42+
43+
(defun trim-paren (string)
44+
(string-trim '(#\( #\)) string))
45+
3746
(defun truth-table (exp)
3847
(with-output-to-string (s)
3948
(let ((inference:*output-stream* s))
@@ -57,9 +66,7 @@
5766
(defmethod update-proposition (table (string string))
5867
(update-proposition
5968
table
60-
(mapcar (lambda (x)
61-
(intern (string-upcase x)))
62-
(str:words (string-trim '(#\( #\)) string)))))
69+
(parse-string string)))
6370

6471
(defmethod render ((table table))
6572
(with-html
@@ -68,7 +75,7 @@
6875
(update-proposition table prop)))
6976
(:input :type "text"
7077
:name "prop"
71-
:placeholder (prop table))
78+
:placeholder (trim-paren (prop table)))
7279
(:input :type "submit"
7380
:value "Eval"))
7481
(:pre (truth table))))
@@ -79,7 +86,7 @@
7986

8087
(defmethod weblocks/session:init ((app truth-table))
8188
(declare (ignorable app))
82-
(create-table *proposition*))
89+
(create-table (parse-string *proposition*)))
8390

8491
(defun start (&optional (port *port*))
8592
(weblocks/debug:on)

0 commit comments

Comments
 (0)