[REBOL] Associative data store Re:(4)
From: agem:crosswinds at: 15-Sep-2000 5:19
[rebol--keithdevens--com] wrote on 14-Sep-2000/19:13:08-4:00
> I really like the path idea. Is there any way to emulate an associative
> array without having to make a special object type?
>
use different types for key/value. for example, use
word! for key, string! for value. this works often,
like i have file! as key and numbers (position etc) as values,
or simple types as keys and blocks as values etc.
'find checks for type, so
find somewhere 'find-me
find somewhere "find-me"
are different.
> Very unfortunately, Rebol doesn't let you just do things like:
> assoc/key: "value"
>
> (if assoc/key doesn't actually exist yet)
>
> is there any way to cheat and do something like:
>
> (fake example that doesn't work)
>
> assoc: make hash! []
> change assoc/key "dude"
>
i use this:
now-is: function [
"change value after key, if it is present, otherwise append both"
series key value] [here]
[
here: find series key
either here [change/only next here value] [append series reduce [key value]]
]