Re: efficiently accumulating values
- From: Alexander Schmolck <a.schmolck@xxxxxxxxx>
- Date: 06 Jul 2006 11:05:23 +0100
liyer.vijay@xxxxxxxxx writes:
liyer.vijay@xxxxxxxxx wrote:
[snip my own stuff]
Hi,
I found the reference in PCL (Peter, if you're reading this, thanks)
to VECTOR-PUSH-EXTEND which dramatically reduces time to 0.346
seconds. Here is the program:
(defun find-words (graph)
"Given GRAPH find all possible words."
(destructuring-bind (m n) (array-dimensions graph)
(loop with result = (make-array 0 :adjustable t :fill-pointer 0)
as i from 0 to (1- m)
do (loop as j from 0 to (1- n)
do (loop as word in (get-words graph i j)
if (and (zerop i) (zerop j))
do (vector-push-extend word result)))
finally (return (coerce result '(or cons list))))))
However, I'd still like to know if there's a better way, and since I
didn't mention it in my last post, any suggestions, comments,
criticisms on coding style, programming are greatly appreciated.
I was about to suggest vector-push-extend. I have only glanced over your code
but I'd think the next thing you could do is pass the vector in to get-words
to be destructively modified there.
.
- Follow-Ups:
- Re: efficiently accumulating values
- From: liyer . vijay
- Re: efficiently accumulating values
- References:
- efficiently accumulating values
- From: liyer . vijay
- Re: efficiently accumulating values
- From: liyer . vijay
- efficiently accumulating values
- Prev by Date: Re: efficiently accumulating values
- Next by Date: Re: ANN: CLPython
- Previous by thread: Re: efficiently accumulating values
- Next by thread: Re: efficiently accumulating values
- Index(es):
Relevant Pages
|