Common sorted list: Difference between revisions

→‎{{header|Clojure}}: Add point-free version
(Add clojure solution)
(→‎{{header|Clojure}}: Add point-free version)
Line 439:
 
=={{header|Clojure}}==
===Efficient transducer & sorted-set version===
<syntaxhighlight lang="lisp">(defn common-sorted [& colls]
(into (sorted-set) cat colls))
Line 444 ⟶ 445:
(common-sorted [5 1 3 8 9 4 8 7] [3 5 9 8 4] [1 3 7 9])
;; => #{1 3 4 5 7 8 9}
</syntaxhighlight>
 
===Point-free, list-based version===
<syntaxhighlight lang="lisp">(def common-sorted (comp sort distinct concat))
 
(common-sorted [5 1 3 8 9 4 8 7] [3 5 9 8 4] [1 3 7 9])
;; => (1 3 4 5 7 8 9)
</syntaxhighlight>
 
15

edits