File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
selection-sort/src/selection_sort Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 11(ns selection-sort.core
22 (:gen-class ))
33
4+ (defn remov
5+ [x args]
6+ (filter (fn [y] (not= x y)) args))
7+
48(defn isort
59 [arg]
610 (loop [sorted-list []
711 unsorted-list arg]
812 (if (empty? unsorted-list)
913 sorted-list
10- (recur (cons (apply min unsorted-list) sorted-list)
11- (remove (fn [x] (= x (apply min unsorted-list))) unsorted-list)))))
14+ (let [minimum (apply min unsorted-list)]
15+ (recur (cons minimum sorted-list)
16+ (remov minimum unsorted-list))))))
1217
1318(defn -main
1419 [& args]
1520 (println (isort (map read-string args))))
1621
22+
23+ ; ; clojure primitive procedure, remove
24+
1725; ; => (remove (fn[x] (= x 3)) '(1 2 3 4 5))
1826; ; (1 2 4 5)
27+
28+ ; ; above self defined procedure, remov
29+
30+ ; ; => (remov 3 '(1 2 3 4 5))
31+ ; ; (1 2 4 5)
You can’t perform that action at this time.
0 commit comments