Moritz, 

Funny, went to IRC after seeing this brought up to respond, and didn't even 
notice you made this the weekly contribution to perl6!  I have a Str.trans 
implementation on my rakudo github fork that's working and passes 20 tests:  

http://github.com/cjfields/rakudo

A few caveats:

1) It's very simplistic and just does alternation mapping using the recent 
regex interpolation additions.  I agree we could switch to .comb if needed.  
Matching against a long list of alternates using captures like /<@alternates>/ 
is very slow (one of the tests bears this out).  If these are somehow 
stringified and maybe regex grouped they may be faster.
2) No regex matching yet, but we do have closures working.
3) :d and :s work, but I don't think these are spec'ed.
4) Simple single char transliteration should be very efficient and could be 
optimized as a special case.
5) A strange bug: the following test does not parse; this broke recently.  Any 
obvious reason why this is breaking?

is("&nbsp;&lt;&gt;&amp;".trans( ['&nbsp;', '&lt;', '&gt;', '&amp;'] =>
    [' ',      '<',    '>',    '&'     ] ),
    " <>&","The array version can map one characters to one-or-more 
characters");

I think, in order to get regexes to work we will need a way of getting the name 
of the matching regex from the Match object somehow.  Any idea how to do that?

chris (pyrimidine)



Reply via email to