[Gsll-devel] inverse of cl-array

Mirko Vukovic mirko.vukovic at gmail.com
Tue Feb 10 13:49:27 UTC 2009


On Tue, Feb 10, 2009 at 5:09 AM, Niitsuma Hirotaka <
hirotaka.niitsuma at gmail.com> wrote:

> I can not find convert function
> #A(...) -> #m(...)
>
> ( cl-array is conversion #m -> #a )
>
> Thus I write the following ,but that looks slow.
> --------------
> (defun coerce-array-to-list (in-array)
>   (map 'list
>           #'identity
>           (make-array (array-total-size in-array)
>                             :element-type (array-element-type in-array)
>                             :displaced-to in-array)))
> ;borrow from
> http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/a925ca60d88d4047/cc06e579dfe840a7?lnk=gst&q=displaced+array
>
>
> (defun appropriate-name (element-type ar)
>  (make-marray element-type  :dimensions (array-dimensions ar)
> :initial-contents  (coerce-array-to-list ar))
> )
> ---------------
>
> usage:
> ( appropriate-name 'double-float #2A((1.0d0 2.0d0) (2.0d0 5.0d0)))
> ->
> #m((1.0d0 2.0d0) (2.0d0 5.0d0)))
>
> _______________________________________________
> Gsll-devel mailing list
> Gsll-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/gsll-devel
>

I don't know an answer better than yours.  I would name the function
gsll-array.
Also, since marray's are objects, you may want to look into its constructor
to see how the array is stored.

I was bitten a few times by the make-marray syntax that requires a list
input.

(As far as I see, lisp's coerce syntax prevents us from customizing it to do
the job we want.)

Mirko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/gsll-devel/attachments/20090210/df1c2d64/attachment.html>


More information about the gsll-devel mailing list