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

[REBOL] Associative data store Re:(4)

From: ryanc:iesco-dms at: 14-Sep-2000 16:57

FYI: Not quite there, but using the one I just posted allows you to do this:
>> assoc/set 'the "dog"
== [the ["dog"]]
>> assoc/get 'the
== "dog"
>> assoc/list/the
== ["dog"]
>>
[rebol--keithdevens--com] wrote:
> I really like the path idea. Is there any way to emulate an associative > array without having to make a special object type? > > 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" > > -------------------------------------------------------------------- > It would be really really nice if RT could give us something like this (hint > hint): > > assoc: make associative! [] > assoc/key: "value" > > 'first could give us the keys > and 'second could give us the values > > Bonus is, it doesn't require any new syntax... no funky assoc{'key'} or > anything. :) > > Keith > > ----- Original Message ----- > From: <[rebol--techscribe--com]> > To: <[list--rebol--com]> > Sent: Thursday, September 14, 2000 5:57 PM > Subject: [REBOL] Associative data store Re:(2) > > > Oh, shucks, > > > > a bug: > > > > >assoc-add: func [assoc [block!] candidates [block!] /local found] [ > > > if is-assoc? assoc [ > > > foreach [key value] candidates [ > > > either found: contains-key? assoc key [ > > > insert at assoc/values index? found value > > > > The line > > > > > insert at assoc/values index? found value > > > > Should be > > > > change at assoc/values index? found value > > > > > ][ > > > insert assoc/keys key > > > insert assoc/values value > > > ] > > > ] > > > return true > > > ] > > > return false > > >] > > > > To quote Joel, "silly me" :-). > > > > > > > > ;- Elan [ : - ) ] > > author of REBOL: THE OFFICIAL GUIDE > > REBOL Press: The Official Source for REBOL Books > > http://www.REBOLpress.com > > visit me at http://www.TechScribe.com > >
-- Ryan Cole Programmer Analyst www.iesco-dms.com 707-468-5400 The problem of language here are really serious. We wish to speak in some way about the structure of the atoms . . . But we cannot speak about atoms in ordinary language. -W. Heisenberg