Hi, Hans. Here's my (miserably failing) attempt: \definedataset[nicedata]
\starttext \startluacode local name = "nicedata" -- For exposition only local function dofactorial(n) local function inner(c,m) if m<2 then return c end return inner(c*m, m-1) end return inner(1,n) end local function factorial(n) local stringn = tostring(n) if job.datasets.collected[name] then return job.datasets.collected[name].factorial[stringn] else local mydata = {[stringn] = tostring(dofactorial(n))} job.datasets.setdata{ name = name, tag = "factorial", data = mydata } return mydata[stringn] end end interfaces.implement{ name = "factorial", public = true, arguments = {"string"}, actions = {tonumber, factorial, context} } \stopluacode \factorial{7} \stoptext What happens is that, in each run, both the first and the second conditions are met, so the compilation is twice as slow, the opposite result of what I meant to do. How do I fix that? Jairo El mié, 24 de mar. de 2021 a la(s) 01:38, Hans Hagen (j.ha...@xs4all.nl) escribió: > On 3/24/2021 5:20 AM, Jairo A. del Rio wrote: > > Thank you very much. It's useful, indeed. However, what I need is to > > bypass TeX (Lua > .tuc) if possible, since all the data I need to handle > > is generated with Lua scripts. > datasets-001.tex in the test suite > > > ----------------------------------------------------------------- > Hans Hagen | PRAGMA ADE > Ridderstraat 27 | 8061 GH Hasselt | The Netherlands > tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl > ----------------------------------------------------------------- >
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________