Skip to content

Generate key via bisection for Cirru(base65 fractional-indexing)

Notifications You must be signed in to change notification settings

Cumulo/bisection-key.cljs

Repository files navigation

bisection-key

Generate a third string key that is in the middle when compared. For example "a" and "b" result in "aT".

Usage

[cirru/bisection-key "0.1.6-a1"]

Clojars Project

Under bisection-key.core:

; make sure the first parameter is littler
(bisection-key.core/bisect "a" "c") ; "b"
(bisection-key.core/bisect "a" "b") ; "aT"
(bisection-key.core/bisect "a34fd" "f3554") ; "c"

bisection-key.core/min-id ; "+"
bisection-key.core/mid-id ; "T"
bisection-key.core/max-id ; "z"

Functions under bisection-key.util:

; (def v {"a" 1, "b" 1})
(key-before v "b") ; "aT"
(key-after v "a") ; "aT"
(key-prepend v) ; "G"
(key-append v) ; "n"
(key-nth v 0) ; "a"
(val-nth v 0) ; 1

(assoc-after v "a" 2) ; (assoc v "aT" 2)
(assoc-before v "b" 2) ; (assoc v "aT" 2)
(assoc-prepend v 2) ; (assoc v "G" 2)
(assoc-append v 2) ; (assoc v "n" 2)
(assoc-nth v 0 2) ; (assoc v "a" 2)
(assoc-before-nth v 1 2) ; (assoc v "aT" 2)
(assoc-after-nth v 1 2) ; (assoc v "n" 2)

(get-min-key v) ; "a"
(get-max-key v) ; "b"

Charset:

+-/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

Workflow

Workflow https://github.com/minimal-xyz/minimal-shadow-cljs-nodejs

License

MIT