For the Compleat Fan
ssqq
Posts: 88 Joined: Sun May 04, 2014 12:49 pm
Post
by ssqq » Wed Jun 11, 2014 2:33 pm
As manual said:
Slices or rest parts of lists or arrays as used in implicit resting or slicing cannot be substituted at once using setf, but would have to be substituted element by element.
.
If I want replace a piece of list to a element:
Code: Select all
(set 'lst '(a b c d e f)
(replace-slice (slice lst 2 3) 'g)
lst --> '(a b g f)
I use:
Code: Select all
(append (nth '(0 1) lst) 'g (nth 5 lst))
If have any other simple way to get result?
rickyboy
Posts: 607 Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia
Post
by rickyboy » Wed Jun 11, 2014 5:07 pm
ssqq wrote: I use:
Code: Select all
(append (nth '(0 1) lst) 'g (nth 5 lst))
If have any other simple way to get result?
That
append expression won't even work.
Code: Select all
> (append (nth '(0 1) lst) 'g (nth 5 lst))
ERR: array, list or string expected : a
However, the following will work.
Code: Select all
> (append (slice lst 0 2) (list 'g) (slice lst 5))
(a b g f)
> ;; or, with implicits:
> (append (0 2 lst) (list 'g) (5 lst))
(a b g f)
(λx. x x) (λx. x x)
ssqq
Posts: 88 Joined: Sun May 04, 2014 12:49 pm
Post
by ssqq » Thu Jun 12, 2014 3:11 am
Sorry, I have test my code.
Thanks a lots.