Hi Andrew,
there is a lot of cases, where your functions won't work as expected, eg.:
blk: copy []
associate blk [2] 3
associate? blk [2]
The other problem is, that your functions won't accept Any-type! values for
Key/Value
Regards
Ladislav
> Here's an implementation for an Associative Data Store (ADS) that uses
only
> two functions, doesn't require an object per ADS and can use any Rebol
value
> as a key. Comment invited. Thanks to Gabriele for showing how to shorten
the
> 'Associate? function.
>
> [
> Rebol [
> Title: "Associate"
> Name: 'Associate
> File: %Associate.r
> Author: "Andrew Martin"
> Email: [EMAIL PROTECTED]
> Date: 18/September/2000
> ]
>
> Associate: function [Block [block!] Key Value] [Index] [
> Index: find Block Key
> either none? Value [
> if found? Index [
> remove/part Index 2
> ]
> ][
> either found? Index [
> change/only next Index reduce [Value]
> ][
> append Block reduce [Key reduce [Value]]
> ]
> ]
> Block
> ]
>
> Associate?: function [Block [block!] Key] [Value] [
> all [
> Value: select Block Key
> first Value
> ]
> ]
> ]
>
> Andrew Martin
> ICQ: 26227169
> http://members.ncbi.com/AndrewMartin/
> http://members.xoom.com/AndrewMartin/
> -><-
>
>