From 1154021614181f2b62ced31cde8b9ac761f91312 Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Fri, 26 Jan 2024 20:35:57 +0100 Subject: refactor: make zippers return 'pop'ped elements --- lib/zipper.mli | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'lib/zipper.mli') diff --git a/lib/zipper.mli b/lib/zipper.mli index 0bbdf27..a300b12 100644 --- a/lib/zipper.mli +++ b/lib/zipper.mli @@ -106,30 +106,18 @@ val goto : int -> 'a zipper -> 'a zipper This involve [push]ing and [pop]ping elements before and after the cursor. *) -val pop : ?n:int -> 'a zipper -> 'a zipper +val pop : ?n:int -> 'a zipper -> 'a Sequence.t * 'a zipper (** Remove [n] elements at the cursor position (1 by default), if any, - and return the modified zipper. Calling [pop z], + and return them alongside the modified zipper. *) - - if [z] is [([3; 2; 1], [4; 5])], the result is [([3; 2; 1], [5])], - - if [z] is [([1; 2; 3], [])], the result is [([1; 2; 3], [])]. - *) - -val pop_before : ?n:int -> 'a zipper -> 'a zipper +val pop_before : ?n:int -> 'a zipper -> 'a Sequence.t * 'a zipper (** Remove [n] elements before the cursor (1 by default), if any, and - return the modified zipper. Calling [pop_before z], - - - if [z] is [([3; 2; 1], [4; 5])], the result is [([2; 1], [4, 5])], - - if [z] is [([], [1; 2; 3])], the result is [([], [1; 2; 3])]. - *) + return them alongside the modified zipper. *) -val pop_after : ?n:int -> 'a zipper -> 'a zipper +val pop_after : ?n:int -> 'a zipper -> 'a Sequence.t * 'a zipper (** Remove [n] elements after (and {b not} including) the cursor - (1 by default), if any, and return the modified zipper. - Calling [pop_after z], - - - if [z] is [([3; 2; 1], [4; 5])], the result is [([3; 2; 1], [4])], - - if [z] is [([1; 2; 3], [4])], the result is [([1; 2; 3], [4])]. - *) + (1 by default), if any, and return them alongside the modified + zipper. *) val push : 'a -> 'a zipper -> 'a zipper (** Insert an element at the cursor position. -- cgit v1.2.3