5 ms·
The equivalent clojure code would be: (defn f [a b] (let [res (join "," (sort (distinct (mapcat keys [a b]))))] (if (empty? res) "<none>" res
by aaroniba 14y ago
The equivalent clojure code would be:
(defn f [a b]
(let [res (join "," (sort (distinct (mapcat keys [a b]))))]
(if (empty? res) "<none>" res)))
Also I'm not a Scala expert, but I think you want .keySet instead of .keys, otherwise they won't be unique, right?
- dxbydt 14y ago> you want .keySet instead of .keys, otherwise they won't be unique, right? scala> val p = Map(1->4,5->3) scala> p.keys res0: Iterable[Int] = Set(1, 5) scala> p.keySet res1: scala.collection.immutable.Set[Int] = Set(1, 5) scala> p.keys++p.keys res2: Iterable[Int] = Set(1, 5) scala> p.keySet++p.keySet res3: scala.collection.immutable.Set[Int] = Set(1, 5)