Re: How to make a copy of a list
- From: "John Thingstad" <jpthing@xxxxxxxxx>
- Date: Wed, 30 Apr 2008 08:12:55 +0200
På Wed, 30 Apr 2008 00:59:58 +0200, skrev Kaz Kylheku <kkylheku@xxxxxxxxx>:
Now we can add multi-dimensional array support. CLOS should match on
VECTOR more specifically if the array is one dimensional, and pass the
greater than rank 2 ones to this specialization:
(defmethod deep-copy ((array array))
;; exercise for reader
)
Good point! But using row-major-aref rather than aref should work for multi-dimentional array's too.
You would need to use array-total-size too.
Or a displacement array.
untested.
(loop for index from 0 below (array-total-size sequence)
do (setf (row-major-aref sequence index) (deep-copy (row-major-aref sequence index)
or
(loop for element across (make-array (array-total-size sequence) :displaced-to sequence)
do (setf element (deep-copy element)))
--------------
John Thingstad
.
- References:
- How to make a copy of a list
- From: Trastabuga
- Re: How to make a copy of a list
- From: John Thingstad
- Re: How to make a copy of a list
- From: John Thingstad
- Re: How to make a copy of a list
- From: John Thingstad
- Re: How to make a copy of a list
- From: Kaz Kylheku
- How to make a copy of a list
- Prev by Date: Re: How to make a copy of a list
- Next by Date: Re: Questions - Higer Order Functions
- Previous by thread: Re: How to make a copy of a list
- Next by thread: Re: How to make a copy of a list
- Index(es):