Oh well, I guess the solution I found is the most stupid around – but at least, I didn't need to think very hard while writing this: 02g1+0^<6?094+-gp.
Why didn't I think of doing the increment in the »loop body« -.-
this has been the first _real_ HVM challenge I did, and I am pretty ashamed of my code. It works but it seems I have to learn a lot more comparing it to the most approaches posted here.
Anyway, I think I'll get some good ideas from here for King Rat
My compiler gives much shorter code when I use a recursive procedure:
219*+ g0^<0:1+$1+$025*cp
(ie. strlen[startPos] := If[memory[startPos]==0,startPos,strlen[startPos+1]])
than when I use iteration:
0749*+3*>749*+3*<<0:1+1-3?11g01-3?11g01-239*+?749*+3*<1+749*+3*> 0219*+6*-g
Note: I think it's awesome to read all the different ways people do this -- I think it's an amazing thing that such a short program in such a terse language can create this beautiful diversity. :]
Hmm, may be I have written too early ... it is not that much compact
When I am thinking about it now ... I immediately come with code shown by m!nus's ...