hi,
once i type the following:
(setq a 'x)
(setq b 'y)
(setq p (append a b))
(list p)
and the interpreter says the x is unbounded. so i try
(setq a '(x))
(setq b '(y))
(setq p (append a b))
(list p)
it returns ((x y)).
i would like to know why the first one fails and the second one success,
and how and i construct a list (a b) by using append.
thanks.
charles
·······@cs.hku.hk (Leung Hing Chau (CE)) writes:
> once i type the following:
> (setq a 'x)
> (setq b 'y)
> (setq p (append a b))
> (list p)
> and the interpreter says the x is unbounded.
Not for me. The error is that X is not a sequence.
> so i try
>
> (setq a '(x))
> (setq b '(y))
> (setq p (append a b))
> (list p)
> it returns ((x y)).
>
> i would like to know why the first one fails and the second one success,
> and how and i construct a list (a b) by using append.
I'm not sure what you want. If A and B are lists, and you want to
merge their elements into a new list, use:
(let ((a '(x))
(b '(y)))
(append a b))
=> (x y)
If, on the other hand, if you simply want to create a list of A and B,
you can use:
(let ((a '(x))
(b '(y)))
(list a b))
=> ((x) (y))
or, for the original values of A and B:
(let ((a 'x)
(b 'y))
(list a b))
=> (x y)
--
Hrvoje Niksic <·······@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
I'm a Lisp variable -- bind me!
·······@cs.hku.hk (Leung Hing Chau (CE)) writes:
> once i type the following:
> (setq a 'x)
> (setq b 'y)
> (setq p (append a b))
> (list p)
> and the interpreter says the x is unbounded. so i try
APPEND's arguments must all be lists. 'x is not a list, it's a
symbol.
> (setq a '(x))
> (setq b '(y))
> (setq p (append a b))
> (list p)
> it returns ((x y)).
>
> i would like to know why the first one fails and the second one success,
> and how and i construct a list (a b) by using append.
you have constructed the list '(a b). it's stored in p. but, since
you called (LIST p), it returns the list of the list '(a b). if you
just ask the interpreter for the value of p, it will print out (a b).
ray jones