Skip to content

Commit 0216fc3

Browse files
authored
Merge pull request #23 from weslleymberg/master
Uses "read-from-string" to parse the input as a lisp list
2 parents 36cd465 + 8523ef4 commit 0216fc3

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

web/webapp.lisp

+5-7
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@
4242

4343
(defun parse-string (string)
4444
"Translate string to a list expression"
45-
(mapcar (lambda (x)
46-
(intern (string-upcase x) :lisp-inference))
47-
(str:words string)))
48-
49-
(defun trim-paren (string)
50-
(string-trim '(#\( #\)) string))
45+
(if (and (str:starts-with-p "(" string)
46+
(str:ends-with-p ")" string))
47+
(read-from-string string)
48+
(read-from-string (str:concat "(" string ")"))))
5149

5250
(defun truth-table (exp)
5351
(with-output-to-string (s)
@@ -81,7 +79,7 @@
8179
(update-proposition table prop)))
8280
(:input :type "text"
8381
:name "prop"
84-
:placeholder (trim-paren (prop table)))
82+
:placeholder (prop table))
8583
(:input :type "submit"
8684
:value "Eval"))
8785
(:pre (truth table))

0 commit comments

Comments
 (0)