On Dec 8, 2004, at 9:18 AM, bob coyne wrote: > > I'd like to displace an (unsigned-byte 8) array to an (unsigned-byte > 32) > array. > But that doesn't seem to be supported (see below). Is there any way to > do this?
The two arrays have different type. Therefore they cannot be displaced (I am positive the CLHS has some wording like this in place). OTOH, the wrath of the programming Goddess Ada will be UNCHECKED upon you for even asking something like this. :) Yet, I see why you are asking, and here is some little code I wrote some time ago to do this sort of things in IMHO a nicer way. Hope it helps. Modifications and suggestions welcome. Note that since you have a wrapper around the "views", you can add your DEFMETHODs to do the conversions you are most likely after. -- Binary/unsupported file stripped by Listar -- -- Type: application/zip -- File: displaced-arrays.zip -- Attached file included as plaintext by Listar -- Cheers Marco > > - Bob > > > ---------------------------------- > >> (setq aa (make-array 100 :element-type '(unsigned-byte 32))) >> (setq bb (make-array 100 :displaced-to aa :element-type > '(unsigned-byte 8))) > > ;; It ignores the supplied element-type > >> (describe bb) > #(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...) is a displaced vector of > length 100. > It has no fill pointer. > Its element type is specialized to (UNSIGNED-BYTE 32). > > ------------------------------------- > > ;; Mapping in the other direction gets an error: > >> (setq cc (make-array 100 :element-type '(unsigned-byte 8))) > #(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...) >> (setq dd (make-array 10 :displaced-to cc :element-type > '(unsigned-byte 32))) > > Error in function MAKE-ARRAY: > One can't displace an array of type (UNSIGNED-BYTE > 32) into another of type > (UNSIGNED-BYTE > 8). > [Condition of type SIMPLE-ERROR] > > > > -- Marco Antoniotti http://bioinformatics.nyu.edu NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488 715 Broadway 10th FL fax. +1 - 212 - 998 3484 New York, NY, 10003, U.S.A.
