From ... From: Erik Naggum Subject: Re: Q: on hashes and counting Date: 2000/10/19 Message-ID: <3180960016357928@naggum.net>#1/1 X-Deja-AN: 683447483 References: <8sl58e$ivq$1@nnrp1.deja.com> <3180944138438226@naggum.net> <6xvgupx8zl.fsf@lant.be> mail-copies-to: never Content-Type: text/plain; charset=us-ascii X-Complaints-To: newsmaster@eunet.no X-Trace: oslo-nntp.eunet.no 971972551 11839 195.0.192.66 (19 Oct 2000 16:22:31 GMT) Organization: Naggum Software; vox: +47 800 35477; gsm: +47 93 256 360; fax: +47 93 270 868; http://naggum.no; http://naggum.net User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.7 Mime-Version: 1.0 NNTP-Posting-Date: 19 Oct 2000 16:22:31 GMT Newsgroups: comp.lang.lisp * Peter Vaneynde | Erik Naggum writes: | | > * The Glauber | > Here's my cut at that task: | > | > (let ((hash (make-hash-table :test #'equal))) | > (with-open-file (stream ...file-args...) | > (handler-case | > (loop | > (let ((vendor (read-sequence stream (make-string 5)))) | (make-string 5) stream | not? Huh? Oh, the argument order. Please be a little more verbose. I have no idea how that got in there. | hash-table-keys is not in the ANSI-spec, nor in ACL5. I guess it's a | new feature of ACL6? Oops, sorry, it's my own, an internal function that knows how the hash-table is laid out and does a quick scan through the keys vector to collect keys. | I suppose it's quite a bit faster then: | (loop for key being the hash-keys in hash collect key) | ? That's exactly what I would suggest for the portable definition. The internal function is twice as fast as this loop. | > Did you compile the Lisp code? Perl _always_ runs slower than Lisp | > for me. Of course, I don't use a (good) toy Lisp like CLISP, but | > Allegro CL, and I generally compile with high optimization | > settings. | | Your solution outruns the Lisp one on this old SPARC here... I hope you meant "Perl", but couldn't bring yourself to type it. :) | > I have a situation not dissimilar to yours, where I have ticker | > codes for various financial instruments, and I found that it paid | > off handsomely to use symbols. Some "modern" Lisp books tell us not | | Symbols in hash-tables or using the plists of the symbols? (I'm | supposing you want to store more then one property per symbol of | course) I let the value slot of the symbols hold one of a variety of objects, according to the type of the financial instrument. I don't use symbols as the keys in hash-tables, I use strings, but that's just an accident of history rather than a conscious decision. | > I agree with everything you say, but I would | > attack to death your right to say it. | > -- Tom Stoppard | | I've been dying to ask in what context this was said... :) Actually, I have no idea. Mark Morford picked this one for the SF Gate Morning Fix one day. I found it hilarious. (He also uses "If this is not what you expected, please alter your expectations" in the disclaimer of the Morning Fix, but someone objected so strongly to my using that as a .signature, I found it worthwhile to pick another one.) #:Erik -- I agree with everything you say, but I would attack to death your right to say it. -- Tom Stoppard