(vector-push 'a' str) is the same as (vector-push 'a 'str) is the same as (vector-push (quote a) (quote str)) -- you're trying to push the symbol A onto the symbol STR.
You probably want VECTOR-PUSH-EXTEND, too.
Search found 106 matches
- Fri Oct 26, 2012 2:22 pm
- Forum: Common Lisp
- Topic: element-type in array..
- Replies: 3
- Views: 5821
- Fri Oct 19, 2012 6:33 am
- Forum: Common Lisp
- Topic: Behaviour of EVAL inside LET
- Replies: 14
- Views: 24908
Re: Behaviour of EVAL inside LET
I found the following example of a strange behaviour of command EVAL inside LET constructions. Executing the code (setf z 666) (let ((z 14)) (print z) (eval '(setf www z)) ) results in printing the value 14 of the variable z inside LET construction, but the variable www takes the value 666, not 14!...
- Fri Oct 19, 2012 6:20 am
- Forum: Common Lisp
- Topic: loop keywords
- Replies: 4
- Views: 9117
Re: loop keywords
They have a really bad sense of aestheticsstackman wrote: Why do some people prefix the loop keywords with a colon?
- Fri Oct 19, 2012 6:15 am
- Forum: Common Lisp
- Topic: Adding element to a sorted list
- Replies: 9
- Views: 18001
Re: Adding element to a sorted list
it's a draft, thus it can be improved probably (especially the (= 1 (length lst)) part). It has O(log N). FWIW, for (= 1 (length list)) do (null (cdr list)) -- or reverse that and the T clause and drop the NULL. Does this thing have to be nondestructive? I want to write something like (defun insert...
- Mon Oct 15, 2012 2:30 pm
- Forum: Common Lisp
- Topic: fractional part of a number
- Replies: 3
- Views: 6566
Re: fractional part of a number
FWIW, (nth-value 1 (floor 1.5))stackman wrote:Hi,
Is there a simple way to return the fractional part of a number in common lisp?
At the moment I am usingbut this seems a bit verbose.Code: Select all
(multiple-value-call (lambda (x y)(declare (ignore x)) y) (floor 1.5))
- Sun Oct 14, 2012 5:23 pm
- Forum: Common Lisp
- Topic: Equality of functions?
- Replies: 9
- Views: 13842
Re: Equality of functions?
Thanks for your detailed answer! Your last remark about "code walker" is most helpful, I shall look at it. As far as I understand your answer, there is no inbuilt standard "code walker" in LISP? It doesn't matter; you can't tell if two functions do the same thing anyway. You can...
- Sun Oct 14, 2012 5:14 pm
- Forum: Common Lisp
- Topic: on dolist..
- Replies: 4
- Views: 7164
Re: on dolist..
(if (listp x) t) doesn't terminate the loop; it just keeps looping, and eventually returns nil. Use (return t)
- Wed Sep 26, 2012 7:00 pm
- Forum: Common Lisp
- Topic: Lambda vs Defun
- Replies: 4
- Views: 7865
Re: Lambda vs Defun
Probably the reason it "doesn't work" is that the output stream doesn't get flushed: "Your name Thomas" is written to the output, but doesn't appear on your screen until much later (or possibly never, if you're doing something weird like running your function and immediately shut...
- Wed Sep 26, 2012 6:39 pm
- Forum: Common Lisp
- Topic: Binary tree insert.
- Replies: 4
- Views: 7385
Re: Binary tree insert.
Your structure uses too many conses. Use (parent left . right) [i.e., (parent . (left . right)) ] rather than (parent (left) (right)) [i.e., (parent . ((left . nil) . ((right . nil)))) ], then you can tell whether, say, "left", is a question or an answer using CONSP. Your original tree loo...
- Sat Nov 05, 2011 3:24 am
- Forum: Common Lisp
- Topic: Insight, Help?
- Replies: 1
- Views: 3272
Re: Insight, Help?
You have several problems there. There are misplaced parentheses, FIT is a list, not a number, and CONS only allocates a new cons cell (you use it as if it modifies TOP; you never use the value, so it just gets thrown away). Try (defun fitrange (list) (loop for fit in list if (<= 1 fit 10) collect f...