tag:blogger.com,1999:blog-12983281.post-79306272055706067082007-09-27T18:57:00.000-07:002008-12-09T19:14:51.060-08:00'Programming Collective Intelligence' in Common Lisp, Chapter 3 - Hierarchical ClustersI have Common Lisp code for Chapter 3 up to Hierarchical Clusters. It's longer and not that interesting, so I'll just put up a <a href="http://blubparadox.googlepages.com/clusters.lisp">link to the code</a>. Once again, map and reduce are taking the place of list comprehensions, but other than that it's not particularly Lispy, no macrology or anything. Maybe next time.<br /><br />Last time's tangent was a shortcut to hash syntax. This time I'm not happy with deleting items out of the middle of adjustable arrays. The code puts items on the end of an array and deletes them out of the middle, from a particular position.<br />In Python it's<br /><code>del clust[lowestpair[0]]</code><br />What I have is<br /><code><br />(defun truep (x) (declare (ignore x)) t)<br />(setf clust (delete-if #'truep clust :start (car lowestpair) :end (1+ (car lowestpair))))<br /></code><br /><br />Instead of PCI's use of the Python Imaging Library or some Lisp equivalent, I used cl-pdf, which was easy to use to make the simple graphs, lines and text. This is the full hierarchical cluster, then a zoom view.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_HdYrIZK4E04/Rvxow201edI/AAAAAAAAACQ/X2Oc-KSKZ5g/s1600-h/ch03-hcluster-dendogram.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_HdYrIZK4E04/Rvxow201edI/AAAAAAAAACQ/X2Oc-KSKZ5g/s400/ch03-hcluster-dendogram.jpg" alt="" id="BLOGGER_PHOTO_ID_5115078465346173394" border="0" /></a><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_HdYrIZK4E04/Rvxo9G01eeI/AAAAAAAAACY/RcxO6-Begfc/s1600-h/ch03-hcluster-dendogram-piece.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_HdYrIZK4E04/Rvxo9G01eeI/AAAAAAAAACY/RcxO6-Begfc/s400/ch03-hcluster-dendogram-piece.jpg" alt="" id="BLOGGER_PHOTO_ID_5115078675799570914" border="0" /></a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12983281-7930627205570606708?l=i-need-closures.blogspot.com'/></div>Richard Cookhttp://www.blogger.com/profile/11838741004941594394noreply@blogger.com8