Whoops, typo, should have been:
"(if (<= (count component1) (count component2))"

Corrected:
(defn register-same-as [{:keys [keys->canonical
canonical->components]
                         :as component-graph}
                        key1 key2]
  (let [canonical1 (keys->canonical key1 key1)
        canonical2 (keys->canonical key2 key2)]
    (if (= canonical1 canonical2) component-graph   ; already the same
      (let [component1 (canonical->components canonical1 [canonical1])
            component2 (canonical->components canonical2 [canonical2])
            ;swap if necessary so component1 is the smaller component
            [canonical1 canonical2 component1 component2] (if (<= (count
component1) (count component2))
                                                            [canonical1
canonical2 component1 component2]
                                                            [canonical2
canonical1 component2 component1])
            new-keys->canonical (into keys->canonical (for [item
component1] [item canonical2]))
            new-canonical->components (-> canonical->components
                                        (dissoc canonical1)
                                        (assoc canonical2 (into component2
component1)))]
        {:keys->canonical new-keys->canonical, :canonical->components
new-canonical->components}))))

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to