I am in tw 5.3.1 node version. Reading the official doc, I see the new “function” filter op.
There is not a single example though. And not much explanation about it.
I understood that for the filter [[one two three]function[grab],[2]]
it would call the regular “grab” function with arguments “one two three” and “2” and returns the output of the grab function.
OK, complete example below:
\define grab(input, rank)
<$let res = {{{ [enlist[$input$]nth[$rank]] }}}><<res>></$let>
\end
<$let a = "one two three"
b = {{{ [enlist<a>function[grab],[2]] }}}
>
<<b>> IS <<grab "un deux trois" 2>>
</$let>
The output is “one IS deux” instead of “two IS deux”.
What is going wrong? I am pretty sure that “grab” is not called within the filter. “one” is just the value for b = {{{ [enlist[one two three]] }}}
Also, I have not understood what [[enlist[one two three]function[grab],[2]]
should do.