lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Feb 14, 2011 at 11:57 AM, Francesco Abbate
<francesco.bbt@gmail.com> wrote:
> Seems the right tool to use. A link please ?

http://snippets.luacode.org/snippets/Lua_Preprocessor_118

(has also the link to the original wiki page)

My example was over-hasty, you need to create some local aliases to
the array components (that is, y is a two dimensional array)

smooth3 = compile ([[
return function (y,f1,f2,n)
  # for d = 1,nk do
  local y$(d) = y[$(d)]
  # end
  for i = 1,n do
     # for d = 1,nk do
     y$(d)[i] = f1*y$(d)[i] + f2*y$(d)[i-1]
    # end
 end
end
]],{nk = 3})

A useful notational convenience would be to allow something like y$d
(i.e. without the parentheses)

compile() is of course not yet written, but that is relatively straightforward.

steve d.