Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 85 lines (73 sloc) 2.358 kB
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18
19 (**
20 Loop module
21 *)
22
23 module For :
24 sig
25
26 (**
27 [range a b acc fct]
28 Bounds:
29 start bound is included, end bound is Excluded.
30 {[
31 For.range 0 10 acc (
32 fun i acc ->
33 (* do something with i and acc, return an acc *)
34 )
35 ]}
36
37 The accumulator is returned without changes if a >= b
38 *)
39 val range : int -> int -> 'a -> (int -> 'a -> 'a) -> 'a
40
41 (*
42 if needed
43 *)
44 (* val down_range *)
45
46 end
47
48 module InitAcc :
49 sig
50 (** init the list with [ fst( f i _) : i C {0..n-1} ] and return the folded accumulator *)
51 val list : int * 'a -> (int -> 'a -> 'b * 'a) -> 'b list * 'a end
52 module FilterMap :
53 sig
54 val array :
55 'a array -> (int -> 'a -> bool) -> (int -> 'a -> 'b) -> 'b array
56 end
57 module Map :
58 sig
59 val list : 'a list -> ('a -> 'b) -> 'b list
60 val array : 'a array -> (int -> 'a -> 'b) -> 'b array
61 val option : 'a option -> ('a -> 'b) -> 'b option
62 end
63 module FoldMap :
64 sig
65 val list : 'a list * 'b -> ('a -> 'b -> 'c * 'b) -> 'c list * 'b
66 val array :
67 'a array * 'b -> (int -> 'a -> 'b -> 'c * 'b) -> 'c array * 'b
68 end
69 module Iter :
70 sig
71 val list : 'a list -> ('a -> unit) -> unit
72 val array : 'a array -> (int -> 'a -> unit) -> unit
73 end
74 module Deprecated :
75 sig
76 val l_fold : 'a list * 'b -> ('a -> 'b -> 'b) -> 'b
77 val l_map : 'a list -> ('a -> 'b) -> 'b list
78 val l_filter : 'a list -> ('a -> bool) -> 'a list
79 val l_filter_map : 'a list -> ('a -> 'b option) -> 'b list
80 val l_for_all : 'a list -> ('a -> bool) -> bool
81 val l_map_flat : 'a list -> ('a -> 'b list) -> 'b list
82 val l_map_sort : 'a list -> ('a -> 'b) -> 'b list
83 val l_iter : 'a list -> ('a -> unit) -> unit
84 end
Something went wrong with that request. Please try again.