<div dir="ltr">Hi, Hans. Here's my (miserably failing) attempt:<br><br>

<p style="margin:0px;text-indent:0px;white-space:pre-wrap">\definedataset[nicedata]</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">\starttext</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">\startluacode</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">local name = "nicedata"</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><br></p><p style="margin:0px;text-indent:0px;white-space:pre-wrap">-- For exposition only<br></p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">local function dofactorial(n)</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">     local function inner(c,m)</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">             if m<2 then return c end </p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">             return inner(c*m, m-1)</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">     end</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">     return inner(1,n)</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">end</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><br></p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">local function factorial(n)</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">     local stringn = tostring(n)</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">     if job.datasets.collected[name] then</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">             return job.datasets.collected[name].factorial[stringn]</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">     else</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">             local mydata = {[stringn] = tostring(dofactorial(n))}</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">             job.datasets.setdata{</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">                     name = name,</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">                     tag  = "factorial",</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">                     data = mydata</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">             }</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">             return mydata[stringn]</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">     end</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">end</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><br></p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">interfaces.implement{</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">     name = "factorial",</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">     public = true,</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">     arguments = {"string"},</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">     actions = {tonumber, factorial, context}</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">}</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap"><br></p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">\stopluacode</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">\factorial{7}</p><p style="margin:0px;text-indent:0px;white-space:pre-wrap">\stoptext </p><p style="margin:0px;text-indent:0px;white-space:pre-wrap"><br></p><p style="margin:0px;text-indent:0px;white-space:pre-wrap">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?<br><br></p><p style="margin:0px;text-indent:0px;white-space:pre-wrap">Jairo<br></p></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">El mié, 24 de mar. de 2021 a la(s) 01:38, Hans Hagen (<a href="mailto:j.hagen@xs4all.nl">j.hagen@xs4all.nl</a>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 3/24/2021 5:20 AM, Jairo A. del Rio wrote:<br>
> Thank you very much. It's useful, indeed. However, what I need is to <br>
> bypass TeX (Lua > .tuc) if possible, since all the data I need to handle <br>
> is generated with Lua scripts.<br>
datasets-001.tex in the test suite<br>
<br>
<br>
-----------------------------------------------------------------<br>
Hans Hagen | PRAGMA ADE<br>
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands<br>
tel: 038 477 53 69 | <a href="http://www.pragma-ade.nl" rel="noreferrer" target="_blank">www.pragma-ade.nl</a> | <a href="http://www.pragma-pod.nl" rel="noreferrer" target="_blank">www.pragma-pod.nl</a><br>
-----------------------------------------------------------------<br>
</blockquote></div>