[stringtemplate-interest] folding with template application
parrt at cs.usfca.edu
Thu Jan 5 16:59:43 PST 2012
On Jan 3, 2012, at 11:22 AM, Wesley Smith wrote:
> Is there an idiom in StringTemplate for apply a fold operation over a
> list? Let's say I have ["f", "g"]. I'd like to generate f(g()). I'm
> not seeing how to make use of the map operation to accumulate results
> recursively into a list to generate the fold operation. Any ideas?
I suspect that this might be easier if you construct nested templates in your model rather than in the view (templates). But, although it doesn't occur to me exactly how to do this at the moment, using first and rest functions and doing the typical functional programming thing of using recursion to iterate down the list might do it.
maybe you need to call a recursive template that starts with a list of names:
func(f,others) ::= "<f>(<func(f=first(others), others=rest(others))>)"
try something like this.
More information about the stringtemplate-interest