William James
11/15/2015 8:01:00 AM
Teemu Likonen wrote:
> Teemu Likonen [2015-11-15 08:48:50+02] wrote:
>
> > NTHCDR is a function (not an accessor) so it can't be used with SETF.
>
> But since this is CL we can create such accessor:
>
> (defun (setf nthcdr*) (new-tail n list)
> (loop :for i :upfrom 0
> :for current := (cons nil list) :then (cdr current)
> :while current
> :if (= i n) :do (return (setf (cdr current) new-tail))))
>
> CL-USER> (let ((list (list 1 2 3 4 5)))
> (setf (nthcdr* 2 list) (list 'a 'b 'c))
> list)
> (1 2 A B C)
MatzLisp (Ruby):
a = [1,2,3,4,5]
==>[1, 2, 3, 4, 5]
a[2 .. -1] = %w(a b c)
==>["a", "b", "c"]
a
==>[1, 2, "a", "b", "c"]
a = [1,2,3,4,5]
==>[1, 2, 3, 4, 5]
a[2 .. -1] = %w(a b c d)
==>["a", "b", "c", "d"]
a
==>[1, 2, "a", "b", "c", "d"]
--
Africans gang-rape and clitorectomize Finnish girl; government arrests Finn
whom they accuse of complaining:
conservative-headlines.com/2009/03/another-european-awaits-extradition-for-hate-speech