tag:blogger.com,1999:blog-5953796462512646386.post8643857411341188525..comments2023-11-09T22:34:37.657-08:00Comments on On Beyond Lambda: On Lisp in Clojure ch 2 (2.7 - 2.10)Rickhttp://www.blogger.com/profile/15734518728736260336noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-5953796462512646386.post-57223396074846356942012-03-06T12:38:49.747-08:002012-03-06T12:38:49.747-08:00Good catch, thanks!Good catch, thanks!Rickhttps://www.blogger.com/profile/15734518728736260336noreply@blogger.comtag:blogger.com,1999:blog-5953796462512646386.post-53118582458301981592012-03-06T08:38:21.100-08:002012-03-06T08:38:21.100-08:00Re count-instances this will work:
(defn count-in...Re count-instances this will work:<br /><br />(defn count-instances [obj lsts]<br /> (defn instances-in [lst]<br /> (if (not (empty? lst))<br /> (+ <br /> (if (= (first lst) obj) 1 0)<br /> (instances-in (rest lst)))<br /> 0))<br /> (map instances-in lsts))<br /><br />In Common Lisp (consp lst) where lst is empty returns false, whereas (seq? lst) in Clojure where lst is empty resturns true.maaclhttps://www.blogger.com/profile/03957062577673090902noreply@blogger.com