Re: Referencing a row in a two dimensional array

Marco Antoniotti <[email protected]>
Newsgroups gmane.lisp.corman
Message-ID <[email protected]>
On Friday, Feb 28, 2003, at 06:11 America/New_York, SmallHairyTroll 
<[email protected]> wrote:

> This is a newbie question, but I can't find an answer in my Lisp
> text:
>
> I have a two dimensional array (MAKE-ARRAY `(,row ,col)). Currently
> I am writing binary data to this array a single byte at a time using
> READ-BYTE from within two nested loops (row & column loops).
>
> I now want to use READ-SEQUENCE to read a chunk of bytes into each
> row, but I'm stumped as to how I can give READ-SEQUENCE a reference
> to just the row of the array. This is easy to accomplish in C using
> pointers, and I am sure it is just as easy in Lisp.

That is because C does not really have multidimensional arrays :)

>
> (READ-SEQUENCE (row-reference-here) in-stream 0 row)
>
> In CLL, is READ-SEQUENCE implemented in a similar fashion to the C
> function "fread" ?
>
> Anyone help?


Essentially you define your row as a "displaced array" to the original 
one and then you can use READ-SEQUENCE on it.  You can do also 
something that you cannot safely do in C.  You can make a vector 
displaced to the whole N-dimensional array and then read in the whole 
thing in one fell swoop using READ-SEQUENCE.

Essentially check out the spec for :displaced-to etc etc in the ARRAY 
section.

Marco

--
Marco Antoniotti
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.


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/FpY02D/vN2EAA/xGHJAA/SyjtlB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[email protected]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.