[luatex] Behavior of node lists.

luigi scarso luigi.scarso at gmail.com
Mon Jul 4 09:42:42 CEST 2011


On Mon, Jul 4, 2011 at 9:22 AM, luigi scarso <luigi.scarso at gmail.com> wrote:
> On Mon, Jul 4, 2011 at 9:06 AM, Paul Isambert <zappathustra at free.fr> wrote:
>> Hello all,
>>
>> Problem 1:
>> %%%
>> \setbox0=\hbox{01}
>>
>> \directlua{
>> local done
>> for n in node.traverse(tex.box[0].head) do
>>  texio.write_nl("Considering " .. string.char(n.char))
>>  if not done then
>>    local next = n.next
>>    done = true
>>    tex.box[0].head = node.remove(tex.box[0].head, n)
>>    tex.box[0].head = node.remove(tex.box[0].head, next)
>>  end
>> end}
>>
>> \box0 \bye
>> %%%
> I've no checked but does it change if you say
> local done=false
> ?
of course no, but it's a matter of style.
I'm always in trouble  when I modify the table that is the argument of
a for loop,
I mean something like
for k,v in pairs(my_table) do
  modify(my_table)
end


-- 
luigi



More information about the luatex mailing list