The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Newsgroups: comp.lang.lisp
From: Kenny Tilton <ktil...@nyc.rr.com>
Date: Fri, 07 Nov 2003 16:51:21 GMT
Local: Fri, Nov 7 2003 11:51 am
Subject: Re: I would appreciate a code review
Artie Gold wrote: This is an FAQ classic: you have to capture the return value from sort. > (defun build-occurences-alist (the-list) > ; the-alist is the result > (let ((the-alist nil)) > (flet ((update-alist (key) > ; have we dealt with this symbol already? > (let ((pos (assoc key the-alist))) > (if pos > ; we have, so increment the count > (incf (cdr pos)) > ; we haven't, so create an entry > (push (cons key 1) the-alist))))) > ; map across the supplied list > (mapc #'update-alist the-list) > ; I can't get the sort to work for some reason > ;(sort the-alist #'> :key #'cdr) > the-alist))) > Aside from the fact that I can't seem to get the SORT to work (any clues Remember, there is no such thing as a list. The local variable the-alist is bound to a cons cell (the first of the list before the sort). after the sort (since you do not code "(setf the-alist (sort the-alist....") it naturally is still bound to the same cons cell, no matter where that cons cell now sits in the structure which followed it until sort destructively rearranged things. Of course in the example above it so happens you do not need the "(setf kenny -- Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film Your Project Here! http://alu.cliki.net/Industry%20Application You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||