Hi, do we have labels equiv. in clojure?
The code below is from OnLisp. Trying to convert to clj file,
but have minor difficulties.


(defun count-instances (obj lsts)
  (labels ((instances-in (lst)
    (if (consp lst)
      (+ (if (eq (car lst) obj) 1 0) (instances-in (cdr lst)))
      0)))
 (mapcar #’instances-in lsts)))

> (count-instances ’a ’((a b c) (d a r p a) (d a r) (a a)))
(1 2 1 2)

thanks
sun

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to