i use this:

change-or-append: func [series key value /local found-here] [
 either found-here: find series :key [change/only next found-here :value]
 [append/only series :key append/only series :value]]

or that

now-known: func [ series key ] [
    if not find series :key [ append/only series :key ] ]

if there is a more 'REBOLlious' way i don't know, 
but special applications are max three-liners.

one point maybe: rebol-hashs are 'double-linked'.
a: [ "german" "deutsch" "REBOL" "REBOL"]
next find a "german" ; english > german 
back find a "deutsch" ; german > english

but [back find a "REBOL"] is wrong translated ..
you need some kind of type-marking.
[word! string! ..] ;automatic different
or 
a: [ "e-german" "g-deutsch" "e-REBOL" "g-REBOL"]
or
a: [[english "german"][german "deutsch"]] 
find/only a [english "german"]
find/only a [german "deutsch"]

Volker

> Hi, just wondering what happened to associative arrays. I understand that
> REBOL's blocks and hashes are powerful, but there's still no easy way as far
> as I know to just say (like you can in Perl, for instance) $blah{'value'} =
> "supercalifragilisticexpialidocious", and get the value by just saying
> $blah{'value'}. Is there something I've missed, or am I looking at things in
> a non-REBOL way? Is there a reason for not providing a data structure that
> works this way?
> 
> I know you can just say something like:
> 
> >> hash: []
> == []
> >> append hash [key "value"]
> == [key "value"]
> >> select hash 'key
> == "value"
> 
> but this allows for duplicate key values, for instance. One of the nifty
> keen things about Perl's hash type is that you can use it as sort of a
> "uniqueness" tester, since the hash keys have to be unique. By just using
> "exists $hash{'key'}" you can tell whether something already has that key
> value. Anyway, you get the idea. If anyone can help me think of this in a
> more 'REBOLlious' way I'd appreciate it. Thanks!
> 
> Keith
> 
> 
> 

Reply via email to