3 let rec step arr dx look stop idx
=
7 match arr
.{idx
+ look
} with
9 | _
-> step arr dx look stop
(idx
+ dx
)
11 (* walk back until we hit the begin of the line *)
12 let back arr idx
= step arr
(-1) (-1) 0 idx
14 (* walk forward until we hit the end of the line *)
15 let forw arr len idx
= step arr
1 0 len idx
17 let line arr len idx
=
18 let off = back arr idx
19 and pos
= forw arr len idx
in
20 pos
- off |> Array1.sub arr
off |> Bigstring.to_string