Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!think!barmar From: barmar@think.COM (Barry Margolin) Newsgroups: comp.lang.lisp Subject: Re: Partially displaced arrays? Message-ID: <25364@news.Think.COM> Date: 25 Jul 89 01:49:53 GMT References: <9562@phoenix.Princeton.EDU> Sender: news@Think.COM Reply-To: barmar@kulla.UUCP (Barry Margolin) Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 27 In article <9562@phoenix.Princeton.EDU> eliot@phoenix.Princeton.EDU (Eliot Handelman) writes: >Supposing this is the array: > ----------------- > | | X | X | X | > ----------------- > | | | | | > ----------------- >I need to create a second array that shares only those locations marked >X, so that changes in those slots are reflected in the "displaced" array. Common Lisp requires that arrays be stored in row-major format. Therefore, assuming your diagram is consistent with that representation, the following should work: (setq array-2 (make-array 3 :displaced-to array-1 :displaced-index-offset 1)) This specifies that the displaced array should only be three elements long and should start at the second element of the original array. Elements 0, 1, and 2 of the displaced array will correspond to elements (0, 1), (0, 2), and (0, 3) of the target array. Barry Margolin Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar