Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions exercises/practice/list-ops/.meta/example.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()))
46 changes: 0 additions & 46 deletions exercises/practice/list-ops/.meta/extra/example-lists.clj

This file was deleted.