[REBOL] Re: Bidirectional value mapping.
From: rotenca:telvia:it at: 3-Nov-2003 21:04
Hello.
> I have 2 values that would be mapped to each other. What I need to do is
> to be able to find the first valeu by searching for the ceond and locate
> the second by searching for the first. I did come up with solutions to
> that but I am not satisfied with any of the solutions. Is there a standard
> Rebol-Way ofr doing that? The best option would be a way that would not
> result in data duplication.
If values are in a block:
>> select [a 1] 'a
== 1
>> first back find [a 1] 1
== a
the last can be wrapped by a function which tests the existence of the value.
bselect: func [blk value][
if blk: find blk value [pick blk -1]
]
---
Ciao
Romano