This implements a key-value data store for RETRO. It's not an optimal solution, but works well enough for smaller data sets.
A store is setup as a linked list with three values:
0 pointer to previous entry 1 pointer to key (string) 2 pointer to value (string) or value (numeric)
This begins with words to access these fields.
Next is a word to make a new store. I create a dummy entry named (nil) as the root.
Searching the store for an entry is next. This is very inefficient due to the use of reorder. If the performance becomes an issue I will revisit it later.
To add or change an entry, I provide kv:set. This is even more inefficient as it scans the store twice when setting an existing entry.
This could be improved:
• only scan once
• factor out the update and add entry actions
The last word is kv:get, which returns the contents of the kv:value field.
And some tests: