Skip to content

Commit

Permalink
Add experimental stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
R1ck77 committed Jan 26, 2019
1 parent 141d42f commit 61ab735
Showing 1 changed file with 90 additions and 1 deletion.
91 changes: 90 additions & 1 deletion src/couchgames/test_utils.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns couchgames.test-utils
(ns it.couchgames.test-utils
(:require [clojure.test :refer :all]))

(defn create-iterator
Expand Down Expand Up @@ -75,3 +75,92 @@ Used like this:

(defn fail [message]
(assert false message))

(defn nested? [group]
(not (empty?
(filter identity (map coll? group)))))

(defn valid-collection? [x]
(or (vector? x)
(set? x)))

(def valid?)

;;; TODO/FIXME mutual recursion without trampolining…
(defn- valid-sub-elements? [group]
(reduce #(and % (valid? %2))
true
(filter coll? group)))

(defn valid? [group]
(and (valid-collection? group)
(not (empty? group))
(valid-sub-elements? group)))

(def all-elements)

(defn- el-type [x]
(if (coll? x)
(cond
(map? x) :map
(set? x) :linear
(or (vector? x)
(list? x)) :linear)
:value))

(defmulti get-elements el-type)

(defmethod get-elements [x] :map
)

(defmethod get-elements [x] :linear
(map )
)

(defmethod get-elements [x] :value
x)

(defn- linear-node-elements [node]
(map (fn [el]
(if (coll? node)
(all-elements node)
node)) node))

(defn- all-node-elements [node]
(case
(map? node) (mapcat (fn [[key rep]]
(repeat rep (if (coll? value)
(all-node-elements key)
key)))
node)
:default (mapcat (fn [value]
(if (coll? value)
(all-node-elements value)
value))
node)))

(defn all-elements [group]
(sort
(filter (complement coll?)
(tree-seq coll? all-node-elements group))))

(defn compliant-sorted-group? [template x])

(defn compliant-unsorted-group? [template x])

(comment
(defmacro with-grouped-invocatins
" [did-it ([:a :b :c] :ordered]
[did-it [:a :b :c]]
[did-it [:a [:a2 :b2 :c2] #{:a3 :b3 :c3}]]
[did-it #{:a #{:b :c} :d [:e :f :g]}]
:e :c :f :d :g :b :a
patologico
[did-it #{:a #{:a :b} :a [:a :b :c]}]
:a :a :a :b :a :c :a
" [x]

))

0 comments on commit 61ab735

Please sign in to comment.