That seems easy enough to solve. Simply record the index and length in pi of the index and length in pi.
See also: Recursion
See also: Recursion