Open ghost opened 4 years ago
Oh, I missed this one. The encoding rule is simple. As you can see, we have constants here:
NEGATIVE_SYLLABLE
: syllable to represent a negative number.SYLLABLES
: an array of syllables, corresponding to each number.Every negative number will be encoded into a word that starts with xa
, then the rest will be treated as a positive number.
The positive number itself will be encoded using division and modulo operation. I'll use 2592 as an example:
SYLLABLES
array) is 92. If we use this as an index for looking up a value in SYLLABLES
array, we'll found yu
syllable.ha
on SYLLABLES
array.hayu
.If the number is negative, it'll be xahayu
. Simple, huh?
Anyway, thanks for that! It's one in my learning-list that I hadn't ever learned until now, I forced myself by writing this crate. 😅
I see, interesting. Did you make the rule yourself, or are you inspired by something?
Cool, working on a project is definitely one of the better ways to learn a language!
Is there any description on the encoding rules? To put more clearly, why do -1 corresponds to xabi, hayu to 2592, and so on?
Also, I see that you made this library to study Rust. Good luck on your journey learning Rust!