more cleanup.

This commit is contained in:
2023-10-28 20:27:00 -07:00
parent 855c23f4ae
commit e8a419fb3c
9 changed files with 142 additions and 121 deletions

View File

@@ -12,17 +12,9 @@
\"foo[bar][][baz]\"
=> [\"foo\" \"bar\" \"\" \"baz\"]"
[param-name]
(let [[_ k ks] (re-matches #"(?s)(.*?)((?:(\[.*?\])|\(.*?\))*)" (name param-name))
keys (if ks (map second (re-seq #"(\[.*?\]|\(.*?\))" ks)))]
(cons k
(map (fn [k]
(let [[_ indexed-match] (re-matches k "\((.*?)\)")
[_ keyed-match] (re-matches k "\[(.*?)\]")]
(if indexed-match
[:index indexed-match]
[:key indexed-match])))))))
(let [[_ k ks] (re-matches #"(?s)(.*?)((?:\[.*?\])*)" (name param-name))
keys (if ks (map second (re-seq #"\[(.*?)\]" ks)))]
(cons k keys)))
(defn- assoc-vec [m k v]
(let [m (if (contains? m k) m (assoc m k []))]