Hi Alexandre,
Meanwhile, I have implemented SVA's first_match
and ##[i:j].
The latter is just syntactic sugar:
a ##[i:j] b = a:([*i:j];b)
##[i:j] b = [*i:j];b
##i = ##[i:i]
While you are at this, maybe you could also implement SVA's ##[*] and ##[+] (as sugar
for ##[0:$] and ##[1:$]) for completeness?
Please also note that the equality a ##[i:j] b = a:([*i:j];b) is wrong (despite being
recommended in some textbooks!), e.g.
{empty_word} ##[0:1] {a} =[by definition] = ({empty_word} ##0 {a}) | ({empty_word} ##1
{a}) = {} | {a} = {a}
but
{empty_word} : ([*0:1];{a}) = {}
The reason is that ##0 always loses the empty word. Hence, it's best to split off ##0
(fusion) from ##[i>0:j] (union of concatenations) and handle them separately.
Regards,
Victor.