Discussion of Common Lisp
-
megera
- Posts: 30
- Joined: Wed Oct 10, 2012 1:34 pm
Post
by megera » Fri Oct 26, 2012 1:05 pm
HI
If I try to make a resizable string with
make-array, but error raises with
vector-push..:
Code: Select all
(defparameter str (make-array 10 :fill-pointer 0 :adjustable t :element-type 'character))
>STR
(vector-push 'a' str) ;;error raise:
value STR is not of the expected type (AND
ARRAY
(SATISFIES
ARRAY-HAS-FILL-POINTER-P)).
[Condition of type TYPE-ERROR]
....?it works without specify :element-type.....but why it's atype error?? 'a' is a char...
thanks in advance!!!
-
Goheeca
- Posts: 271
- Joined: Thu May 10, 2012 12:54 pm
-
Contact:
Post
by Goheeca » Fri Oct 26, 2012 2:16 pm
Because
'a' isn't a character. This works:
-
Paul
- Posts: 106
- Joined: Tue Jun 02, 2009 6:00 am
Post
by Paul » Fri Oct 26, 2012 2:22 pm
(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.
-
megera
- Posts: 30
- Joined: Wed Oct 10, 2012 1:34 pm
Post
by megera » Sat Oct 27, 2012 1:29 am
opss'!!!
perfect thanks!