Debian Codegraph @

clib/neList.ml

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 type 'a t = 'a * 'a list
12
13 let head (x,_) = x
14
15 let tail (_,tl) = match tl with
16 | [] -> None
17 | y::tl -> Some (y,tl)
18
19 let singleton x = x,[]
20
21 let iter f (x,tl) =
22 f x;
23 List.iter f tl
24
25 let map f (x,tl) =
26 let x = f x in
27 let tl = List.map f tl in
28 x, tl
29
30 let map2 f (x,tl) (x',tl') =
31 let x = f x x' in
32 let tl = List.map2 f tl tl' in
33 x, tl
34
35 let map_head f (x,tl) = f x, tl
36
37 let push x = function
38 | None -> x, []
39 | Some (y,tl) -> x, y::tl
40
41 let to_list (x,tl) = x::tl
42
43 let of_list = function
44 | [] -> invalid_arg "NeList.of_list"
45 | x::tl -> x,tl
46
47 let repr x = x
48
49 let of_repr x = x