|
43 | 43 | * for lo <= i < hi, iteratively do b = f (b, i) *)
|
44 | 44 | val loop: (int * int) -> 'a -> ('a * int -> 'a) -> 'a
|
45 | 45 |
|
| 46 | + val all: (int * int) -> (int -> bool) -> bool |
| 47 | + val exists: (int * int) -> (int -> bool) -> bool |
| 48 | + |
46 | 49 | val copyListIntoArray: 'a list -> 'a array -> int -> int
|
47 | 50 |
|
48 | 51 | val revMap: ('a -> 'b) -> 'a list -> 'b list
|
49 | 52 |
|
50 | 53 | val intToString: int -> string
|
| 54 | + |
| 55 | + val equalLists: ('a * 'a -> bool) -> 'a list * 'a list -> bool |
| 56 | + |
51 | 57 | end =
|
52 | 58 | struct
|
53 | 59 |
|
@@ -138,6 +144,22 @@ struct
|
138 | 144 | ForkJoin.parfor 4096 (0, ArraySlice.length s)
|
139 | 145 | (fn i => f (i, ArraySlice.sub (s, i)))
|
140 | 146 |
|
| 147 | + fun all (lo, hi) f = |
| 148 | + let |
| 149 | + fun allFrom i = |
| 150 | + (i >= hi) orelse (f i andalso allFrom (i+1)) |
| 151 | + in |
| 152 | + allFrom lo |
| 153 | + end |
| 154 | + |
| 155 | + fun exists (lo, hi) f = |
| 156 | + let |
| 157 | + fun existsFrom i = |
| 158 | + i < hi andalso (f i orelse existsFrom (i+1)) |
| 159 | + in |
| 160 | + existsFrom lo |
| 161 | + end |
| 162 | + |
141 | 163 | fun copyListIntoArray xs arr i =
|
142 | 164 | case xs of
|
143 | 165 | [] => i
|
@@ -323,4 +345,10 @@ struct
|
323 | 345 | toInt v
|
324 | 346 | end)
|
325 | 347 |
|
| 348 | + |
| 349 | + fun equalLists eq ([], []) = true |
| 350 | + | equalLists eq (x :: xs, y :: ys) = |
| 351 | + eq (x, y) andalso equalLists eq (xs, ys) |
| 352 | + | equalLists _ _ = false |
| 353 | + |
326 | 354 | end
|
0 commit comments