I'm trying to understand the basics of lua programming within LaTeX.
I have this simple function in a file called luatest.lua
:
function fact (n) if n == 0 then return 1 else return n * fact(n-1) endend
Then I have an usual .tex file:
\documentclass{article}\directlua{dofile("luatest.lua")}\newcommand{\myluafact}[1]{\directlua{function fact(#1)}} \begin{document} test \myluafact{5}\end{document}
Which unfortunately does not compile. It seems to me that I'm missing some tex.sprint()
somewhere, but where?