[toronto-lisp] March meeting minutes.

doug at hcsw.org doug at hcsw.org
Thu Mar 11 03:31:25 UTC 2010


On Tue, Mar 09, 2010 at 10:12:32PM -0500 or thereabouts, Abram Hindle wrote:
> Well if I use copy-seq I get this error from sbcl:
> 
> unhandled TYPE-ERROR in thread #<SB-THREAD:THREAD "initial thread"
> RUNNING {10026F2EC1}>:
>   The value
>     #2A((#\# #\# #\# #\#)
>         (#\# #\1 #\  #\#)
>         (#\# #\# #\  #\#)
>         (#\# #\  #\  #\#)
>         (#\# #\2 #\# #\#)
>         (#\# #\# #\# #\#))
>   is not of type
>     SEQUENCE.

Ya like I said in my last message that was my mistake. I meant to say
vectors are sequences so can be copied with copy-seq. Arrays are not
sequences.


> (defun copy-array (array)
> ;  (copy-seq array))
>   (let ((dims (array-dimensions array)))
>     (adjust-array
>      (make-array dims :displaced-to array)
>      dims)))
> 
> Where as this does not.

Nice one though it might be a good idea to propagate the element type too
so stuff like this doesn't happen:

* (make-array '(2 2) :element-type '(unsigned-byte 8))

#2A((0 0) (0 0))

* (copy-array *)

Error in function MAKE-ARRAY:
   One can't displace an array of type T into another of type (UNSIGNED-BYTE 8).
   [Condition of type SIMPLE-ERROR]


I think this is a bit better (but probably still isn't complete because
of not copying fill pointers and whatnot):

(defun copy-array (array)
  (let ((dims (array-dimensions array)))
    (adjust-array
     (make-array dims :displaced-to array
                      :element-type (array-element-type array))
     dims)))




More information about the toronto-lisp mailing list