Skip to content

Commit

Permalink
No, hash is fine here and faster, input is sorted anyway so there is …
Browse files Browse the repository at this point in the history
…no place that needs to assume an alphabetical order, so this was not an issue. Doc also updated.
  • Loading branch information
patham9 committed Oct 18, 2016
1 parent 49ec41a commit ddc84ea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/nal.deriver.normalization.html
Original file line number Diff line number Diff line change
Expand Up @@ -2923,13 +2923,13 @@
['-- (sort-commutative (second conclusions))]
(let [f (first conclusions)]
(if (commutative-ops f)
(vec (conj (sort-by str (drop 1 conclusions)) f))
(vec (conj (sort-by hash (drop 1 conclusions)) f))
conclusions)))
conclusions))</pre></td></tr><tr><td class="docs"><p>the union set operation for extensional and intensional sets</p>

<p>https://gist.github.com/TonyLo1/a3f8e05458c5e90c2e72</p>
</td><td class="codes"><pre class="brush: clojure">(defn union
([c1 c2] (sort-by str (set (concat c1 c2))))
([c1 c2] (sort-by hash (set (concat c1 c2))))
([op c1 c2] (vec (conj (union c1 c2) op))))</pre></td></tr><tr><td class="docs"><p>the difference set operation for extensional and intensional sets</p>
</td><td class="codes"><pre class="brush: clojure">(defn diff
([c1 c2] (into '() (set/difference (set c1) (set c2))))
Expand Down
4 changes: 2 additions & 2 deletions docs/uberdoc.html
Original file line number Diff line number Diff line change
Expand Up @@ -3406,13 +3406,13 @@
['-- (sort-commutative (second conclusions))]
(let [f (first conclusions)]
(if (commutative-ops f)
(vec (conj (sort-by str (drop 1 conclusions)) f))
(vec (conj (sort-by hash (drop 1 conclusions)) f))
conclusions)))
conclusions))</pre></td></tr><tr><td class="docs"><p>the union set operation for extensional and intensional sets</p>

<p>https://gist.github.com/TonyLo1/a3f8e05458c5e90c2e72</p>
</td><td class="codes"><pre class="brush: clojure">(defn union
([c1 c2] (sort-by str (set (concat c1 c2))))
([c1 c2] (sort-by hash (set (concat c1 c2))))
([op c1 c2] (vec (conj (union c1 c2) op))))</pre></td></tr><tr><td class="docs"><p>the difference set operation for extensional and intensional sets</p>
</td><td class="codes"><pre class="brush: clojure">(defn diff
([c1 c2] (into '() (set/difference (set c1) (set c2))))
Expand Down
4 changes: 2 additions & 2 deletions src/nal/deriver/normalization.clj
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@
['-- (sort-commutative (second conclusions))]
(let [f (first conclusions)]
(if (commutative-ops f)
(vec (conj (sort-by str (drop 1 conclusions)) f))
(vec (conj (sort-by hash (drop 1 conclusions)) f))
conclusions)))
conclusions))

;https://gist.github.com/TonyLo1/a3f8e05458c5e90c2e72
(defn union
"the union set operation for extensional and intensional sets"
([c1 c2] (sort-by str (set (concat c1 c2))))
([c1 c2] (sort-by hash (set (concat c1 c2))))
([op c1 c2] (vec (conj (union c1 c2) op))))

(defn diff
Expand Down

0 comments on commit ddc84ea

Please sign in to comment.