I tried to add a repeat refinement to build-markup function using the previous answer: How to bind to foreach context?
build-markup: func [
{Return marku
For:
words: [num]
vals: [1 2 3]
When you use foreach :words
, you are creating a new context for which the repeat block will be bound to. The word!
contents of :words
are not actually bound to this new context. The values you are getting suggest 'a
is globally set to 1 and 'b
is set to [a b]
. To illustrate:
>> num: 9
== 9
>> words: [num]
== [num]
>> foreach :words vals [
[ probe get 'num
[ probe get first :words
[ ]
1
9
2
9
3
9
== 9
To work around this, try to picture that for each iteration of the loop, the block that is executed is 'bind
-ed to the loop context. You can preempt the bind like this:
foreach :words vals probe compose/only [
probe get first (words)
]
(probe left in for illustrative purposes)