[luatex] print versus tex.print

Paul Isambert zappathustra at free.fr
Mon Jan 23 17:32:37 CET 2012


Herbert Voss <Herbert.Voss at fu-berlin.de> a écrit:
> 
> Am 23.01.2012 15:47, schrieb Paul Isambert:
> 
> >> \directlua{table.foreach(os.date("!*t"),function(...)
> >> tex.print(tostring(...) end)}
> >> \bye
> >
> > Or use a test like "type(<arg>) == 'boolean'". Note that table.foreach
> 
> I alread had tostring() but I thought there might be
> an easier solution.
> 
> > is deprecated in Lua 5.1 and should be removed from 5.2 (see:
> > http://lua-users.org/lists/lua-l/2010-11/msg00661.html). And LuaTeX
> 
> oh, I like that ... :-(

You can easily fake it:

table.foreach = table.foreach or
  function (t, f)
    for k, v in pairs(t) do
      local ret = f(k, v)
      if ret then return ret end
    end
  end

table.foreachi = table.foreach or
  function (t, f)
    for k, v in ipairs(t) do
      local ret = f(k, v)
      if ret then return ret end
    end
  end

Best,
Paul



More information about the luatex mailing list