Oh wow, this is perfect! brb, off to reimplement the python slicing semantics in OCaml:
let (.@[;..]) ls = function[@warning "-8"]
| [| start; -1 |] ->
List.to_iter ls
|> Iter.zip_i
|> Iter.drop_while (Pair.fst_map ((>) start))
|> Iter.map snd
| [| start; finish |] ->
List.to_iter ls
|> Iter.zip_i
|> Iter.drop_while (Pair.fst_map ((>) start))
|> Iter.take_while (Pair.fst_map ((>) finish))
|> Iter.map snd
| [| start; finish; step |] ->
List.to_iter ls
|> Iter.zip_i
|> Iter.drop_while (Pair.fst_map ((>) start))
|> Iter.take_while (Pair.fst_map ((>) finish))
|> Iter.filter (Pair.fst_map (fun ind -> (ind - start) mod step = 0))
|> Iter.map snd