Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

How to use Hash index

 [1/10] from: moeller_thorsten::GMX::De at: 22-Aug-2003 16:55


Hi, is there anybody out there who can shortly describe to me how hash is working and how to use it in rebol. A little sample with nestedt blocks would be nice. Cheers Thorsten -- COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test -------------------------------------------------- 1. GMX TopMail - Platz 1 und Testsieger! 2. GMX ProMail - Platz 2 und Preis-Qualitätssieger! 3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post

 [2/10] from: greggirwin:mindspring at: 22-Aug-2003 9:48


Hi Thorsten, TM> is there anybody out there who can shortly describe to me how hash is TM> working and how to use it in rebol. A little sample with nestedt blocks TM> would be nice. A hash! works like a block!, but is much faster for lookups. One difference is that there is no direct "lexical" format for hash! values; you have to convert other block values to them or use "make hash!"
>> h: make hash! [A [a b c] B [1 2 3] C [! * ~]]
== make hash! [A [a b c] B [1 2 3] C [! * ~]]
>> h/b
== [1 2 3]
>> h/b: [4 5 6]
== make hash! [A [a b c] B [4 5 6] C [! * ~]] Does that help? -- Gregg

 [3/10] from: g:santilli:tiscalinet:it at: 22-Aug-2003 17:58


Hi Gregg, On Friday, August 22, 2003, 5:48:52 PM, you wrote: GI> One GI> difference is that there is no direct "lexical" format for hash! GI> values; you have to convert other block values to them or use "make GI> hash!" Actually, there is, and now is available in the release version of Core too. (View's release version still lacks this syntax.)
>>> h: make hash! [A [a b c] B [1 2 3] C [! * ~]]
h: #[hash! [A [a b c] B [1 2 3] C [! * ~]]] :-) Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/

 [4/10] from: cyphre:seznam:cz at: 22-Aug-2003 18:40


Hi all, lexical format of hash! works from REBOL/View 1.2.5
>> load #[hash![1 2 3]]
== make hash! [1 2 3] regards, Cyphre

 [5/10] from: greggirwin:mindspring at: 22-Aug-2003 10:46


Hi Gabriele, GI>> One difference is that there is no direct "lexical" format for hash! GI>> values; you have to convert other block values to them or use "make GI>> hash!" GS> Actually, there is, and now is available in the release version of GS> Core too. (View's release version still lacks this syntax.)
>>>> h: make hash! [A [a b c] B [1 2 3] C [! * ~]]
GS> h: #[hash! [A [a b c] B [1 2 3] C [! * ~]]] GS> :-) Hmmmm, I *suppose* that counts. ;) For those of you who don't know, what Gabriele posted is the serialized format of a hash, which can now be used directly.
>> mold h
== "make hash! [A [a b c] B [1 2 3] C [! * ~]]"
>> mold/all h
== "#[hash![A [a b c] B [1 2 3] C [! * ~]]]" --Gregg

 [6/10] from: moeller_thorsten:GMX at: 22-Aug-2003 19:44


Hi all, thanks to all responding to my question and for giving me such a short and precise explanation. This rises up another question. Are the any known performance issues concerning filesize or numbers of blocks or depth of nesting? Cheers Thorsten

 [7/10] from: robert:muench:robertmuench at: 23-Aug-2003 13:37


> -----Original Message----- > From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]
<<quoted lines omitted: 3>>
> Subject: [REBOL] Re: How to use Hash index > A hash! works like a block!, but is much faster for lookups.
Hi, IIRC I once talked to Carl and he said, that everything in Rebol is hashed anyway. So I really don't know if there is a performance difference. Robert

 [8/10] from: g:santilli:tiscalinet:it at: 23-Aug-2003 16:31


Hi Robert, On Saturday, August 23, 2003, 1:37:00 PM, you wrote: RMM> Hi, IIRC I once talked to Carl and he said, that everything in Rebol is RMM> hashed anyway. So I really don't know if there is a performance RMM> difference. Robert I don't think blocks are. Maybe he was referring to words in contexts etc. Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/

 [9/10] from: greggirwin:mindspring at: 23-Aug-2003 8:46


Hi Thorsten, TM> This rises up another question. Are the any known performance issues TM> concerning filesize or numbers of blocks or depth of nesting? Different block types are better at different things. list! values are faster at inserting and removing items, and hash! values are faster at looking items up. I think both have a case or two--with certain iteration functions for example--where they behave differently than a plain block!. I don't know of any limits. The trick is to use natives whenever you can to do the work as they can be much faster. If you know how much data you want to handle, just generate some random data and do some tests against it. REBOL makes it easy to do that. -- Gregg

 [10/10] from: greggirwin:mindspring at: 23-Aug-2003 8:55


Hi Robert, RMM> Hi, IIRC I once talked to Carl and he said, that everything in Rebol is RMM> hashed anyway. So I really don't know if there is a performance RMM> difference. Robert I see a pretty big difference with the following. (almost 3 seconds for blocks, and just ~.15 for hashes) x: copy [] insert/dup x "ABCDEFG" 250 b: append x ["AAAAAA" "BBBBBB" "CCCCCCC" "DDDDDD" "EEEEEE" "FFFFFFF"] h: make hash! b t: now/time/precise repeat i 100000 [select b "EEEEEE"] print ["block:" now/time/precise - t] t: now/time/precise repeat i 100000 [select h "EEEEEE"] print ["hash:" now/time/precise - t] t: now/time/precise repeat i 100000 [find b "EEEEEE"] print ["block:" now/time/precise - t] t: now/time/precise repeat i 100000 [find h "EEEEEE"] print ["hash:" now/time/precise - t] -- Gregg

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted