Handbook
Glossary
ulid>bytes ( ulid -- byte-array )
Universally Unique Lexicographically Sortable Identifier
Prev:
ulid ( -- ulid )
Next:
bytes>ulid ( byte-array -- ulid )
Vocabulary
ulid
Inputs
ulid
a
string
Outputs
byte-array
a
byte-array
Word description
Convert a string
ulid
into its binary representation.
Errors
ulid>bytes-bad-length
( n -- * )
ulid>bytes-bad-character
( ch -- * )
ulid>bytes-overflow
( -- * )
Definition
USING:
binary-search
kernel
math
math.order
sequences
ulid.private
;
IN:
ulid
:
ulid>bytes
( ulid -- byte-array )
dup
length
dup
26
=
[
drop
]
[
ulid>bytes-bad-length
]
if
[
dup
[
>=<
]
curry
encoding
swap
search
pick
=
[
nip
]
[
drop
ulid>bytes-bad-character
]
if
]
B{
}
map-as
dup
first
7
>
[
ulid>bytes-overflow
]
when
pack-bits
;