Re: efficiently accumulating values
- From: liyer.vijay@xxxxxxxxx
- Date: 6 Jul 2006 00:45:35 -0700
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.
Cheers
Vijay
Can we quote you on that?A long time ago, someone in the Lisp industry told me it was poor form
quote people; it suggests that they lack value.
-- Kent M Pitman <pitman@xxxxxxxxxxxxx> in comp.lang.lisp
.
- Follow-Ups:
- Re: efficiently accumulating values
- From: Alexander Schmolck
- Re: efficiently accumulating values
- From: Pascal Bourguignon
- Re: efficiently accumulating values
- References:
- efficiently accumulating values
- From: liyer . vijay
- efficiently accumulating values
- Prev by Date: Re: ANN: CLPython
- Next by Date: Re: ACL versus SBCL?
- Previous by thread: Re: efficiently accumulating values
- Next by thread: Re: efficiently accumulating values
- Index(es):
Relevant Pages
|