Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
VEBER Philippe
codepi
Commits
805f6a43
Commit
805f6a43
authored
Oct 26, 2020
by
Louis Duchemin
Browse files
Implements toolbox.Utils.range_for_all with tests
parent
08949d34
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
lib/toolbox/utils.ml
lib/toolbox/utils.ml
+12
-0
No files found.
lib/toolbox/utils.ml
View file @
805f6a43
...
...
@@ -25,6 +25,18 @@ let range_iter a b ~f =
in
loop
a
let
range_for_all
a
b
~
f
=
let
rec
loop
i
=
i
=
b
||
(
f
i
&&
loop
(
i
+
1
))
in
loop
a
let
%
test
"range_for_all 1..4 <= 10"
=
range_for_all
1
4
~
f
:
((
>=
)
10
)
let
%
test
"not (range_for_all 1..4 <= 2)"
=
not
@@
range_for_all
1
4
~
f
:
((
>=
)
2
)
let
%
test
"not (range_for_all 1..4 <= 0)"
=
not
@@
range_for_all
1
4
~
f
:
((
>=
)
2
)
let
int_fold
a
b
~
init
~
f
=
let
rec
loop
acc
i
=
if
i
>=
b
then
acc
else
loop
(
f
acc
i
)
(
i
+
1
)
in
loop
init
a
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment