[英]ST4 iterate a list with an index
So I have a list that is iterated over like so: 所以我有一个像这样迭代的列表:
body(foo) ::= "<foo:{it|<\n><\n><bar(it)>}>"
bar(x) ::= "[<x.key>:<x.value>]"
I'd like to use the index. 我想使用索引。
bar(x) ::= "[<i0>:<x.key>:x.value>]"
I saw that there is an <i>
and <i0>
index token, but I don't understand how it is used, or if it could be used to do what I want to do. 我看到有一个<i>
和<i0>
索引令牌,但是我不明白它是如何使用的,或者是否可以用来做我想做的事情。
Ok, so the trick is to pass <i>
or <i0>
in if you have a function, but i is implicitly available inside an iterator: 好了,关键是要通过<i>
或<i0>
如果您有一个函数,但我是默认可用一个迭代里面:
body(foo) ::= "<foo:{it|<\n><\n><bar(i0,it)>}>"
bar(i,x) ::= "[<i>:<x.key>:<x.value>]"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.