Hi Premshree, On Wednesday, 29-December-2004 at 3:18:10 Premshree wrote,
>On Tue, 28 Dec 2004 16:16:14 EST, [EMAIL PROTECTED] <[EMAIL PROTECTED]> >wrote: >> >> Premshree: >> >> > I'm trying to write a function that accepts a key as an argument, and >> > then returns the corresponding value. >> >> You might be better off with the keys as strings rather than words: >> >> hsh: make hash! ["a" [1 2] "b" [3 4]] >> >> The code hardly needs a function: >> >> select hsh "b" >> == [3 4] > >Ah, I din't know of the existence of a select. :-| Incidentally, if you did use words as your keys (as apposed to strings), you wouldn't even need SELECT... >> hsh: make hash! [a [1 2] b [3 4]] == make hash! [a [1 2] b [3 4]] >> hsh/a == [1 2] >> hsh/b == [3 4] >> hsh/b/1 == 3 >> hsh/b/2 == 4 >> of: 'a no: 1 == 1 >> hsh/:of/:no == 1 >> of: 'b no: 2 == 2 >> hsh/:of/:no == 4 I'm not sure why Sunanda suggested using strings, but I'm sure there's a good reason - possibly because of the limit to the number of words allowed in REBOL. Or perhaps for speed reasons. Sunanda? -- Carl Read. -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.298 / Virus Database: 265.6.6 - Release Date: 12/28/04 -- To unsubscribe from the list, just send an email to rebol-request at rebol.com with unsubscribe as the subject.
