clisp

How can I improve clisp error messages?

人盡茶涼 提交于 2019-12-22 18:06:37
问题 I have been dabbling a little with clisp. It is a little perplexing that it doesn't print out the line number an error is at. Or, at least a general hint where the error is located. In some cases that must be possible, right? Is there any way I can get better error messages? 回答1: As in most questions I see involving clisp, the answer is probably "don't use clisp". As you might be aware, clisp is but one of many implementations of Common Lisp, and probably not one of the more popular ones.

Understanding tailp in Common Lisp

自闭症网瘾萝莉.ら 提交于 2019-12-22 08:29:32
问题 While looking through the "Common Lisp Quick Reference" by Bert Burgemeister, I stumbled over tailp . First, I misunderstood the definitions of this function. And I tried: (tailp '(3 4 5) '(1 2 3 4 5)) But it returned NIL CLTL2 says, tailp is true iff the first argument is any (nthcdr n list) with existing n . (nthcdr 2 '(1 2 3 4 5)) ;; (3 4 5) I further tried: (tailp '(3 4 5) '(1 2 3 4 5)) ;; NIL - and I would expect: T following the definition above. (tailp '() '(1 2 3 4 5)) ;; T (tailp '5

Why does (list 'quote 'x) evaluate to 'x and not ('x) or (quote 'x)?

只谈情不闲聊 提交于 2019-12-19 07:47:33
问题 I'm trying to learn LISP and was going through a code example where something similar to the following code is used: (list 'quote 5) This evaluates to '5 in the REPL. I expected it to evaluate to ('5) or (quote 5) I'm trying this out in the CLISP REPL. Any help would be appreciated. 回答1: The read-evaluate-print loop first reads, then evaluates 'quote is read as "the symbol whose name is QUOTE" 5 is read as "the number 5" So (list 'quote 5) is evaluated as "make a list whose first element is

Why does (list 'quote 'x) evaluate to 'x and not ('x) or (quote 'x)?

我与影子孤独终老i 提交于 2019-12-19 07:47:06
问题 I'm trying to learn LISP and was going through a code example where something similar to the following code is used: (list 'quote 5) This evaluates to '5 in the REPL. I expected it to evaluate to ('5) or (quote 5) I'm trying this out in the CLISP REPL. Any help would be appreciated. 回答1: The read-evaluate-print loop first reads, then evaluates 'quote is read as "the symbol whose name is QUOTE" 5 is read as "the number 5" So (list 'quote 5) is evaluated as "make a list whose first element is

combining two variables into one function name in macro

流过昼夜 提交于 2019-12-17 20:54:40
问题 I was toying around with macros and clos, where I created an "object" macro to create instances (defmacro object (class &rest args) `(make-instance ',class ,@args)) Now doing this, I also ended up kind of wanting to do something similar for accessor functions created by clos. Example: (defclass person () ((name :accessor person-name :initarg :name))) then creating the instance (setf p1 (object person :name "tom")) now to get the name from the object obviously I would call person-name, however

ASDF output redirection

血红的双手。 提交于 2019-12-14 02:38:53
问题 I would like to set directory where ASDF stores compiled files. I prefer to do it from a shell script. According to this page, one should define environment variable ASDF_OUTPUT_TRANSLATIONS . OK, here it is: $ export ASDF_OUTPUT_TRANSLATIONS="$HOME/.cache/common-lisp/my-dir/" But when I try to test the configuration, it does not work: $ clisp -x "(asdf:compile-system :my-system)" Output: ;; Loading file /home/mark/.clisprc.lisp ... ;; Loading file /home/mark/quicklisp/setup.lisp ... *** -

Solving recursive Towers of Hanoi in Lisp

◇◆丶佛笑我妖孽 提交于 2019-12-13 02:18:32
问题 My code in lisp is as follows: (defun solve-hanoi(from) (hanoi (length from) from '() '())) (defun hanoi(height from to aux) (when (>= height 1) (hanoi (- height 1) from aux to) (format t "~%Move ~a from ~a to ~a" (nth 0 from) from to) (push (pop from) to) (hanoi (- height 1) aux to from))) I am new to lisp and have NO clue as to what I am doing wrong. Help with this would be GREATLY appreciated since I've been at this for hours. Thanks. 回答1: The recursive algorithm is: To move n discs from

lisp - should be a lambda expression

拟墨画扇 提交于 2019-12-12 10:23:54
问题 I'm trying to return (values str ((+ x 3) y)) from the function it resides in. code snippet: (if (<my condition>) (values str ((+ x 3) y)) (values str ((+ x 2) y))) gives error: (+ X 3) SHOULD BE A LAMBDA EXPRESSION but (values str (y (+ x 3))) works fine. why? 回答1: The S-expression ((+ x 3) y) cannot be evaluated because the first list element is not funcallable (it should name a function or be a lambda expression). So, to avoid evaluation, you need to quote it: (if (<my condition>) (values

Sort Polynomial based on Symbol and Exponent

丶灬走出姿态 提交于 2019-12-12 06:46:27
问题 I'm writing writing polynomial arithmetic in lisp, and currently working on addition. I need help sorting a polynomial by the exponent and symbol. My polynomials are represented as follows: ((3 ((1 x)(1 y))) (1 ((3 y)))) ; == 3xy + 1y^3 The function I need guidance with is given a term like ((5 ((3 x))) (3 ((3 y))) (4 ((2 z)))) ((6 ((3 x))) (1 ((3 y))) (9 ((2 z))))) I would want: ((4 ((2 Z))) (9 ((2 Z))) (5 ((3 X))) (6 ((3 X))) (3 ((3 Y))) (1 ((3 Y)))) returned, so that all So all z^2 and z^2

Local variable keeps data from previous execution

家住魔仙堡 提交于 2019-12-12 02:48:21
问题 ith the code below, even though (I believe) I'm only using local variables in each function, the result after running multiple times looks like data remain in variables and it ends up adding old & new result. What is wrong? (defun funcC (target res) (cond ((null res) (list (list target 1))) ((equal (car (car res)) target) (setf (cadr (car res)) (+ (cadr (car res)) 1)) res) (t (setf (cdr res) (funcC target (cdr res))) res) )) (defun funcB (l res) (cond ((null l) nil) ((atom l) (funcC l res)) (