From ... Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed1.e.nsc.no!nsc.no!nextra.com!uio.no!nntp.uio.no!not-for-mail From: Erik Naggum Newsgroups: comp.lang.lisp Subject: Re: simple-array vs displaced-to Date: 17 Jan 2004 21:38:04 +0000 Organization: Naggum Software, Oslo, Norway Lines: 33 Message-ID: <3283364284060266KL2065E@naggum.no> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: readme.uio.no 1074375484 1416 129.240.65.210 (17 Jan 2004 21:38:04 GMT) X-Complaints-To: abuse@uio.no NNTP-Posting-Date: Sat, 17 Jan 2004 21:38:04 +0000 (UTC) Mail-Copies-To: never User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 Xref: archiver1.google.com comp.lang.lisp:10202 * Martin Raspaud | One would say "why not give as parameter to the processing funtion | the big array and an offset ?" Well, I don't really like this, it | doesn't feel the right way to do it to me. | | So am I wrong with this or is there another solution, ie having a kind | of displaced-to array that would be a simple-array ? One common optimization when working with non-simple arrays is to dig out the underlying simple-array and the start and end positions that a displaced array makes into one convenient object. The function ARRAY-DISPLACEMENT returns the values of the arguments :DISPLACED-TO and and :DISPLACED-INDEX-OFFSETgiven to MAKE-ARRAY or ADJUST-ARRAY, or NIL and 0 if it was not displaced. (defun undisplace-array (array) "Return the fundamental array and the start and end positions into it of a displaced array." (let ((length (length array)) (start 0)) (loop (multiple-value-bind (to offset) (array-displacement array) (if to (setq array to start (+ start offset)) (return (values array start (+ start length)))))))) -- Erik Naggum | Oslo, Norway Act from reason, and failure makes you rethink and study harder. Act from faith, and failure makes you blame someone and push harder.