[REBOL] Re: Bidirectional value mapping.
From: maximo:meteorstudios at: 3-Nov-2003 16:07
Hi Bruno,
I'm sorry If I have induced you into error, but I did not understand the question in
the proper way...
If you want to map a series of values to-from, then liquid isn't really the thing to
use... I thought you meant to keep a synchronisation between to entities... so that
a change in one repercutes as a change to the other...
But, just using select a reverse on a series, makes it map one value to another, if you
want to map the other way, you need to use reverse (but, of course, you need to know
the direction of the search):
list: ["a" 1 "b" 2 "c" 3]
select list "b"
==2
select (head reverse copy list) 2
==
b
note that the parentheses aren't necessary, I just added them to increase readability.
I've read that they can affect performance, so they should be removed when used in real
code.
HTH
-MAx
---
You can either be part of the problem or part of the solution, but in the end, being
part of the problem is much more fun.