def len.of

bend-kit-redis@0.3.0.0 · redis.bend:299

import bend-kit-redis@0.3.0.0/redis.bend as Redis
import Base

299# A length or count below 2^31; -1 (RESP2 null) is 4294967295 and anything else is 4294967294.
300def len.of(n: Num) -> U32:
301  Num{+neg, +hi, +lo, +ok} = n
302  +nil = Bool.and(ok, Bool.and(neg, Bool.and(U32.is_eq(hi, 0), U32.is_eq(lo, 1))))
303  +good = Bool.and(ok, Bool.and(Bool.not(neg), Bool.and(U32.is_eq(hi, 0), U32.is_lt(lo, 2147483648))))
304  Bool.pick(U32, good, lo, Bool.pick(U32, nil, 4294967295, 4294967294))

Uses (7)

Used by (2)