Sha256: 3d30e35be96a328b715f8dcbcbf0b55b8cc8e1719e0dced088ea24811f52e00b

Contents?: true

Size: 605 Bytes

Versions: 216

Compression:

Stored size: 605 Bytes

Contents

(ns sublist)

(defn- list-contains?
  "Returns truthy when list2 is contained within list1, nil otherwise"
  [list1 list2]
  (some #(when (= % list2) val)
        (partition (count list2) 1 list1)))

(defn classify
  "Classifies two lists based on whether coll1 is the same list, a superlist,
  a sublist, or disjoint (unequal) from coll2."
  [coll1 coll2]
  (let [len1 (count coll1)
        len2 (count coll2)]
    (cond
      (= coll1 coll2) :equal
      (and (> len1 len2) (list-contains? coll1 coll2)) :superlist
      (and (> len2 len1) (list-contains? coll2 coll1)) :sublist
      :else :unequal)))

Version data entries

216 entries across 216 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.179 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.178 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.177 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.176 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.175 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.174 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.173 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.172 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.171 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.170 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.169 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.167 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.166 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.165 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.164 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.163 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.162 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.161 tracks/clojure/exercises/sublist/src/example.clj
trackler-2.2.1.160 tracks/clojure/exercises/sublist/src/example.clj