Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion I would appreciate a code review

Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!elnk-pas-nf1!newsfeed.earthlink.net!pd7cy1no!pd7cy2so!shaw.ca!news-out.superfeed.net!propagator2-maxim!news-in-maxim.spamkiller.net!news.usc.edu!news.isi.edu!usenet
From: t...@sevak.isi.edu (Thomas A. Russ)
Newsgroups: comp.lang.lisp
Subject: Re: I would appreciate a code review
Date: 07 Nov 2003 12:24:24 -0800
Organization: USC-ISI
Lines: 23
Message-ID: <ymid6c4vsef.fsf@sevak.isi.edu>
References: <90ac4ec2.0311061901.658716ba@posting.google.com>
	<wku15gfz7g.fsf@nhplace.com> <3FAB75B9.E9A1D925@setf.de>
NNTP-Posting-Host: sevak.isi.edu
X-Newsreader: Gnus v5.3/Emacs 19.34

james anderson <james.ander...@setf.de> writes:

> other than the lack of generality, what are the arguments against using the
> provided data itself for the intermediate storage?
> 
> (defun occurrences (list)
>   (let ((key (gensym)))
>     (dolist (item list)
>       (incf (get item key 0)))
                   ^^^^
You are assuming here that item has to be a symbol.  That would fail if
the input included things like integers as well.

>     (mapcar #'(lambda (sym) (prog1 (cons sym (get sym key))
>                               (remprop sym key)))
>             (sort (remove-duplicates list) #'>
>                   :key #'(lambda (sym) (get sym key))))))
> 
> ?

-- 
Thomas A. Russ,  USC/Information Sciences Institute