From ... From: Erik Naggum Subject: Re: Converting an array into a list Date: 1998/10/07 Message-ID: <3116780426375122@naggum.no>#1/1 X-Deja-AN: 398750637 References: mail-copies-to: never To: amit@usc.edu Organization: Naggum Software; +47 8800 8879; http://www.naggum.no Newsgroups: comp.lang.lisp * Amit Kumar | I'm a newbie, first of all, so please treat the question as such. Is | there a trivial way of converting a matrix into a list? ie, if we have a | matrix #2A((a b) (c d)), is there a simple way of getting the list ((a b) | (c d)), short of scanning the entire matrix element by element and | writing to a list? well, the Lisp printer already does this, so we could be clever and do (read-from-string (write-to-string ) t t :start 3) 3 is OK as a constant because: (1) you're not going to use it on one-dimensional arrays, anyway, because (coerce 'list) already does that, (2) you're not going to use it on matrices of more than 9 dimensions, and (3) you know full well this is a clever hack to get past a roadblock on your way to a better world, not a lasting solution. also note that this is not efficient in _any_ way. to get an efficient and lasting solution, you need to traverse the matrix and cons up your own lists of elements. (tip of the day: start from the far end -- you'll avoid the need to reverse the lists you're building.) #:Erik