[REBOL] Nested blocks - retrieving and setting with variables
From: chalz:earthlink at: 24-Sep-2004 1:30
Howdy. First post in a long time; haven't been playing with REBOL much.
However, I have a problem I wanted to handle in REBOL, and I'm kind of stuck
at a point.
Consider:
matrix: [[0 1 2 3 4] [1 0 0 0 0] [2 0 0 0 0]]
i: 2
j: 3
x: 5
I want to set one value within one of the nested blocks to another value.
However, i and j are variable, and this is looped, and I need to modify i
and j in the process of using them. For instance, this is what I've got
right now, and I really don't like it:
do rejoin compose ["matrix/" (i + 1) "/" (j + 1) ": " x]
Also, I get x by comparing a couple values within matrix. For instance,
in another language I work in that's C-like:
min(mtx[si][ti + 1] + 1, mtx[si + 1][ti] + 1, mtx[si][ti] + cost);
Shy of using 'pick' a dozen times, or compose like above, anyone have
recommendations as to how best (simplest) to do that? I know I can do
matrix/:i/:j
But I can't do math on the variables there. Suggestions? Thanks.
--Charles