diff --git a/exercises/practice/list-ops/.meta/example.clj b/exercises/practice/list-ops/.meta/example.clj index 7aa1541cb..75bd2c578 100644 --- a/exercises/practice/list-ops/.meta/example.clj +++ b/exercises/practice/list-ops/.meta/example.clj @@ -48,3 +48,53 @@ (if (neg? index) result (recur (dec index) (conj result (coll index)))))) + + +;;Solves the appendix challenge +;; +;;(ns list-ops) +;; +;;(declare foldl) +;;(declare reverse-order) +;; +;;(defn append +;; [coll1 coll2] +;; (reverse-order (foldl conj coll2 (reverse-order coll1)))) +;; +;;(defn concatenate +;; [colls] +;; (foldl append colls ())) +;; +;;(defn select-if +;; [pred coll] +;; (let [reducer (fn [acc el] +;; (if (pred el) +;; (conj acc el) +;; acc))] +;; (reverse-order (foldl reducer coll ())))) +;; +;;(defn length +;; [coll] +;; (let [reducer (fn [acc _] +;; (inc acc))] +;; (foldl reducer coll 0))) +;; +;;(defn apply-to-each +;; [f coll] +;; (let [reducer (fn [acc el] +;; (conj acc (f el)))] +;; (reverse-order (foldl reducer coll ())))) +;; +;;(defn foldl +;; [f coll acc] +;; (if (seq coll) +;; (recur f (rest coll) (f acc (first coll))) +;; acc)) +;; +;;(defn foldr +;; [f coll acc] +;; (foldl f (reverse-order coll) acc)) +;; +;;(defn reverse-order +;; [coll] +;; (foldl conj coll ())) diff --git a/exercises/practice/list-ops/.meta/extra/example-lists.clj b/exercises/practice/list-ops/.meta/extra/example-lists.clj deleted file mode 100644 index 94b9c89e2..000000000 --- a/exercises/practice/list-ops/.meta/extra/example-lists.clj +++ /dev/null @@ -1,46 +0,0 @@ -(ns list-ops) - -(declare foldl) -(declare reverse-order) - -(defn append - [coll1 coll2] - (reverse-order (foldl conj coll2 (reverse-order coll1)))) - -(defn concatenate - [colls] - (foldl append colls ())) - -(defn select-if - [pred coll] - (let [reducer (fn [acc el] - (if (pred el) - (conj acc el) - acc))] - (reverse-order (foldl reducer coll ())))) - -(defn length - [coll] - (let [reducer (fn [acc _] - (inc acc))] - (foldl reducer coll 0))) - -(defn apply-to-each - [f coll] - (let [reducer (fn [acc el] - (conj acc (f el)))] - (reverse-order (foldl reducer coll ())))) - -(defn foldl - [f coll acc] - (if (seq coll) - (recur f (rest coll) (f acc (first coll))) - acc)) - -(defn foldr - [f coll acc] - (foldl f (reverse-order coll) acc)) - -(defn reverse-order - [coll] - (foldl conj coll ()))