Ranks: strings that sort where an item was put, and always leave room for another between any two.
A rank is digits in base 62, from 0 to 9, A to Z and a to z. It's read as a fraction with no trailing zero, and compared as a string. At either end of a list, the ranks count up or down like numbers, so they stay short however long the list grows.
This is fractional indexing as Wallace describes it in Realtime Editing of Ordered Sequences (Figma, 2017), except that the ranks count like numbers at the ends: https://www.figma.com/blog/realtime-editing-of-ordered-sequences/
Ranks: strings that sort where an item was put, and always leave room for another between any two. A rank is digits in base 62, from 0 to 9, A to Z and a to z. It's read as a fraction with no trailing zero, and compared as a string. At either end of a list, the ranks count up or down like numbers, so they stay short however long the list grows. This is fractional indexing as Wallace describes it in Realtime Editing of Ordered Sequences (Figma, 2017), except that the ranks count like numbers at the ends: https://www.figma.com/blog/realtime-editing-of-ordered-sequences/
(after before n)(after before n tag)The n ranks after the rank before, or the first n of a list for
nil, in a block of their own for the tag if given, e.g. the device's
id. It throws for a before that isn't a rank.
(after "V" 3) ;=> ("W" "X" "Y")
(after nil 2) ;=> ("V" "W")
(after "V" 3 "phone") ;=> ("Wf8V" "Wf8W" "Wf8X")
Without a block, the items that two devices add after the same rank at the same time get the same ranks, and mix. A single rank needs no block.
The `n` ranks after the rank `before`, or the first `n` of a list for
nil, in a block of their own for the `tag` if given, e.g. the device's
id. It throws for a `before` that isn't a rank.
(after "V" 3) ;=> ("W" "X" "Y")
(after nil 2) ;=> ("V" "W")
(after "V" 3 "phone") ;=> ("Wf8V" "Wf8W" "Wf8X")
Without a block, the items that two devices add after the same rank at
the same time get the same ranks, and mix. A single rank needs no
block.(between before after)A rank between the ranks before and after, where nil stands for an
end of the list. It throws for anything that isn't a rank, or when
before doesn't sort before after.
(between nil nil) ;=> "V"
(between "V" nil) ;=> "W"
(between "V" "W") ;=> "VV"
(between nil "V") ;=> "U"
A rank between the ranks `before` and `after`, where nil stands for an
end of the list. It throws for anything that isn't a rank, or when
`before` doesn't sort before `after`.
(between nil nil) ;=> "V"
(between "V" nil) ;=> "W"
(between "V" "W") ;=> "VV"
(between nil "V") ;=> "U"(rank? x)Whether x is a rank: a string of digits that doesn't end in a zero.
Whether `x` is a rank: a string of digits that doesn't end in a zero.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |