Skip to content

Commit

Permalink
Add unid function (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
verberktstan authored Jan 27, 2024
1 parent 754d4d5 commit f9cdadb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/swark/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@
(when input
(some-> input name str/trim non-blank))))

(defn unid
([] (-> (random-uuid) str))
([existing]
(-> existing set? assert)
(reduce
(fn [s char]
(if (and s (-> s existing not) (-> s reverse first #{"-"} not))
(reduced s)
(str s char)))
nil
(seq (unid)))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Regarding keywords

Expand Down

0 comments on commit f9cdadb

Please sign in to comment.