example: refactor the key value store a little

FossilOrigin-Name: 63cb8c39fdb4b8d78224d6ea1b76d749fc34064e772f49e61703b3d6a6b70e15
This commit is contained in:
crc 2019-01-15 18:00:35 +00:00
parent a564b5aad5
commit cd1b64729a

View file

@ -49,10 +49,12 @@ This could be improved:
- factor out the update and add entry actions
~~~
:kv:update-entry (vsD-) kv:lookup kv:value store ;
:kv:add-entry (vsD-) here over [ [ fetch , , , ] dip ] dip store ;
:kv:set (vsD-)
dup-pair kv:lookup n:-zero?
[ kv:lookup kv:value store ]
[ here over [ [ fetch , , , ] dip ] dip store ] choose ;
[ kv:update-entry ] [ kv:add-entry ] choose ;
~~~
The last word is `kv:get`, which returns the contents of the