1

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.

Novaterata
  • 4,356
  • 3
  • 29
  • 51

1 Answers1

2

Ok, so the trick is to pass <i> or <i0> in if you have a function, but i is implicitly available inside an iterator:

 body(foo) ::= "<foo:{it|<\n><\n><bar(i0,it)>}>"

 bar(i,x) ::= "[<i>:<x.key>:<x.value>]"
Novaterata
  • 4,356
  • 3
  • 29
  • 51