tree.bend checks
raw source on the hub · import bend-bpe-tokenizer@0.1.0.0/tree.bend as Tree
Balanced search trees for the Unicode tables (tables.bend): code point ranges to a value, code points to a list, and code point pairs to a code point. A lookup walks one path: each node hands the branch it takes to a helper as a closure, so the branch not taken is never evaluated.
1 import
import Base
Types
type RT source · line 6 · raw
Data
RTipRT
RNode@lo:U32 -> @hi:U32 -> @v:U32 -> @l:RT -> @r:RT -> RT
type KT source · line 10 · raw
Data
KTipKT
KNode@k:U32 -> @v:List<&2, U32> -> @l:KT -> @r:KT -> KT
type PT source · line 14 · raw
Data
PTipPT
PNode@a:U32 -> @b:U32 -> @p:U32 -> @l:PT -> @r:PT -> PT
Definitions
def rt_side source · line 19 · raw
@lt:Bool -> @gt:Bool -> @v:U32 -> @go_l:(@_:Unit -> U32) -> @go_r:(@_:Unit -> U32) -> U32
x below the node, above it, or in it
def rt_find source · line 29 · raw
@t:RT -> @+c:U32 -> U32
the value of the range holding c, or 0
def kt_side source · line 36 · raw
@lt:Bool -> @eq:Bool -> @v:List<&2, U32> -> @go_l:(@_:Unit -> Maybe<&2, List<&2, U32>>) -> @go_r:(@_:Unit -> Maybe<&2, List<&2, U32>>) -> Maybe<&2, List<&2, U32>>
def kt_find source · line 46 · raw
@t:KT -> @+c:U32 -> Maybe<&2, List<&2, U32>>
the list stored for c, if any
def pt_order2 source · line 53 · raw
@yb:Bool -> @ye:Bool -> U32
def pt_order source · line 63 · raw
@xa:Bool -> @xe:Bool -> @yb:Bool -> @ye:Bool -> U32
(x, y) against the node's (a, b), in lexicographic order
def pt_pick source · line 72 · raw
@lt:Bool -> @eq:Bool -> @p:U32 -> @go_l:(@_:Unit -> Maybe<&2, U32>) -> @go_r:(@_:Unit -> Maybe<&2, U32>) -> Maybe<&2, U32>
def pt_side source · line 81 · raw
@+o:U32 -> @p:U32 -> @go_l:(@_:Unit -> Maybe<&2, U32>) -> @go_r:(@_:Unit -> Maybe<&2, U32>) -> Maybe<&2, U32>
def pt_find source · line 85 · raw
@t:PT -> @+x:U32 -> @+y:U32 -> Maybe<&2, U32>
the code point stored for the pair (x, y), if any