Skip to content

Commit 2610b4f

Browse files
Jan Rochelvasilisp
Jan Rochel
authored andcommitted
Ocsigen_lib.List.split_at
1 parent da2423b commit 2610b4f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/baselib/ocsigen_lib_base.ml

+7
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ module List = struct
173173
| [] -> []
174174
| x :: xs -> chop (n-1) xs
175175

176+
let rec split_at n xs =
177+
if n <= 0
178+
then [], xs
179+
else match xs with
180+
| [] -> [], []
181+
| x::xs -> let l,r = split_at (n-1) xs in x::l, r
182+
176183
end
177184

178185
(*****************************************************************************)

src/baselib/ocsigen_lib_base.mli

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ module List : sig
9191
val is_prefix : 'a list -> 'a list -> bool
9292

9393
val chop : int -> 'a list -> 'a list
94+
val split_at : int -> 'a list -> 'a list * 'a list
9495

9596
end
9697

0 commit comments

Comments
 (0)