Fix some typos

This commit is contained in:
Alexander Rosenberg 2024-09-06 14:58:47 -07:00
parent 0a73cf3295
commit 3fc927fee8
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730
2 changed files with 30 additions and 17 deletions

View File

@ -163,13 +163,19 @@ non-nil, allow names to be more than one character long."
finally finally
(let ((str (coerce token 'string))) (let ((str (coerce token 'string)))
(return (return
;; the multi-char token is an operator. its a variable, so defer (string
;; to multi-char-names (cond
(if (or multi-char-names ;; single character unary operand
((let ((val (operator-symbol (string (first token)))))
(and (symbolp val) (unary-p val)))
(first token))
;; multi-char variable, constant (true or false), or operator
((or multi-char-names
(operator-symbol str) (operator-symbol str)
(symbolp (interpret-operand str))) (symbolp (interpret-operand str)))
str str)
(string (first token))))))) ;; single letter variable (multi-char-names is off)
(t (first token))))))))
(defun next-token (str &key multi-char-names) (defun next-token (str &key multi-char-names)
"Return a list of the next token in STR and how much whitespace it had." "Return a list of the next token in STR and how much whitespace it had."

View File

@ -109,7 +109,7 @@
else else
collect char))) collect char)))
(defun typeset-proposition (expr &optional (defun typeset-proposition (expr &key
(lookup-table *operator-ascii-lookup-alist*) (lookup-table *operator-ascii-lookup-alist*)
var-name-transform var-name-transform
(parent-prec most-positive-fixnum)) (parent-prec most-positive-fixnum))
@ -143,19 +143,25 @@ use (it controls when parentheses are applied.)"
(if (null args) (if (null args)
;; we have one argument ;; we have one argument
(format nil "~A~A~A~A" (car prefix-suffix) oper-ascii (format nil "~A~A~A~A" (car prefix-suffix) oper-ascii
(typeset-proposition first-arg lookup-table (typeset-proposition first-arg
var-name-transform our-prec) :lookup-table lookup-table
:var-name-transform var-name-transform
:parent-prec our-prec)
(cdr prefix-suffix)) (cdr prefix-suffix))
;; we have many arguments ;; we have many arguments
(loop for arg in args (loop for arg in args
collect oper-ascii into output collect oper-ascii into output
collect collect
(typeset-proposition arg lookup-table (typeset-proposition arg
var-name-transform our-prec) :lookup-table lookup-table
:var-name-transform var-name-transform
:parent-prec our-prec)
into output into output
finally finally
(push (typeset-proposition first-arg lookup-table (push (typeset-proposition first-arg
var-name-transform our-prec) :lookup-table lookup-table
:var-name-transform var-name-transform
:parent-prec our-prec)
output) output)
(return (format nil "~A~{~A~^ ~}~A" (car prefix-suffix) (return (format nil "~A~{~A~^ ~}~A" (car prefix-suffix)
output (cdr prefix-suffix)))))))))) output (cdr prefix-suffix))))))))))
@ -168,8 +174,8 @@ NOTE: though the overall order does not matter, the order must be the same
between each row." between each row."
(let ((typeset-exprs (mapcar (lambda (expr) (let ((typeset-exprs (mapcar (lambda (expr)
(typeset-proposition (typeset-proposition
expr *operator-latex-lookup-alist* expr :lookup-table *operator-latex-lookup-alist*
'latex-var-name-transform)) :var-name-transform 'latex-var-name-transform))
(extract-truth-table-expressions table)))) (extract-truth-table-expressions table))))
(format nil "~ (format nil "~
\\begin{tabular}{~{~*|c~}|}~ \\begin{tabular}{~{~*|c~}|}~
@ -200,8 +206,8 @@ NOTE: though the overall order does not matter, the order must be the same
between each row." between each row."
(let ((typeset-exprs (mapcar (lambda (expr) (let ((typeset-exprs (mapcar (lambda (expr)
(typeset-proposition (typeset-proposition
expr *operator-html-lookup-alist* expr :lookup-table *operator-html-lookup-alist*
'html-var-name-transform)) :var-name-transform 'html-var-name-transform))
(extract-truth-table-expressions table)))) (extract-truth-table-expressions table))))
(format nil "~ (format nil "~
<table~@[ class=~s~]~@[ id=~s~]~{ ~A~}>~ <table~@[ class=~s~]~@[ id=~s~]~{ ~A~}>~
@ -274,7 +280,8 @@ length of each column."
NOTE: though the overall order does not matter, the order must be the same NOTE: though the overall order does not matter, the order must be the same
between each row." between each row."
(let* ((typeset-exprs (mapcar (lambda (expr) (let* ((typeset-exprs (mapcar (lambda (expr)
(typeset-proposition expr expr-lookup-table)) (typeset-proposition
expr :lookup-table expr-lookup-table))
(extract-truth-table-expressions table))) (extract-truth-table-expressions table)))
(col-widths (mapcar (lambda (expr) (col-widths (mapcar (lambda (expr)
(+ (length expr) 2)) (+ (length expr) 2))