[REBOL] Re: hash questions
From: robert:muench:robertmuench at: 8-Jan-2002 13:58
> -----Original Message-----
> From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]On Behalf Of
> David Hawley
> Sent: Tuesday, January 08, 2002 6:16 AM
> To: [rebol-list--rebol--com]
> Subject: [REBOL] Re: hash questions
> I come from the perl, tcl world where hashes aremoe like array indicies.
Hi, that's what I have in mind too when thinking about hash datastructure.
> In rebol, it seems that I can build a hash list, of some arbitray
> values, but cannot associate keys with data. Am I missing soemthing?
If I understand the hash! in Rebol correct, it's a special datastructure
supporting fast searched. Everything you insert can be searched for with find. I
assume that find uses the best seach-algorithm depending on the datastructure it
searches on (can someone from RT validate this?).
So now to use your idea about (key,value). This can be done and it's only a
thing you have to change in mind. Just insert your key value pait into the hash.
If you now search for the key your value will be the next entry in the hash!
;-))
myhash: hash! [key1 value1 key2 value2]
value1 can be found with: next find myhash 'key1
--
Robert M. Munch
IT & Management Freelancer
Mobile: +49 (0)177 2452 802
Fax : +49 (0)721 8408 9112
Web : http://www.robertmuench.de