I suspect the code below can be improved. The function returns the set
of all symbols inside a list-tree that are not at the beginning of a
list. Is there a way to make the code more compact or faster?

(with-test
  (defn- find-dependencies
    [rel-rep]
    (cond
      (list? rel-rep)
        (let [[_ & tail] rel-rep]
          (into #{} (mapcat find-dependencies tail)))
      (symbol? rel-rep)
        #{rel-rep}
      :default
        nil))
  (is (= '#{a b c}
         (find-dependencies
           '(+ b (- c 3 a))))))

--~--~---------~--~----~------------~-------~--~----~
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
Note that posts from new members are moderated - please be patient with your 
first post.
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