Hi list! See the following example:

\startluacode

userdata = userdata or {}


--Toy example

--My actual function receives an argument, but the problem remains the same


userdata.myfunction = function()

return

"343327959841638047651959775267761420323" ..

"657838053757849835434002826851807933276" ..

"324327913964298509889902373459201557839" ..

"84828001486412574060553756854137069878601"

end


interfaces.implement{

name = "myfunction",

public = true,

actions =

function ()

context(userdata.myfunction())

end

}

\stopluacode

\def\colorfulnumbers#1{\colored[h=\luaexpr{40*#1},s=1,v=1]{#1}\ }%

\starttext

%It doesn't work

%\handletokens{\myfunction}\with\colorfulnumbers

\expandafter\handletokens\expandafter{\myfunction}\with\colorfulnumbers

\stoptext


As readily seen from my example, I want to color each figure of the numbers generated by a Lua function. However, the use of \expandafter's is cumbersome in this case. I don't want to loop over the result in Lua because I want to be able to apply \handletokens...\with... (or another macro with a similar purpose) with different macros at the TeX end once Lua has delivered results. How should I do it in ConTeXt?

Thanks in advance. Cordially,

Jairo