Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Why3
why3
Commits
e35119d5
Commit
e35119d5
authored
Nov 19, 2010
by
François Bobot
Browse files
Ajout de petite fonction utile
parent
2f93f077
Changes
4
Show whitespace changes
Inline
Side-by-side
src/util/sysutil.ml
View file @
e35119d5
...
...
@@ -39,6 +39,11 @@ let channel_contents_buf cin =
let
channel_contents
cin
=
Buffer
.
contents
(
channel_contents_buf
cin
)
let
rec
fold_channel
f
acc
cin
=
try
fold_channel
f
(
f
acc
(
input_line
cin
))
cin
with
End_of_file
->
acc
let
file_contents_fmt
f
fmt
=
try
let
cin
=
open_in
f
in
...
...
src/util/sysutil.mli
View file @
e35119d5
...
...
@@ -26,6 +26,9 @@ val channel_contents_buf : in_channel -> Buffer.t
(* put the content of an in_channel in a formatter *)
val
channel_contents_fmt
:
in_channel
->
Format
.
formatter
->
unit
(* fold on the line of a file *)
val
fold_channel
:
(
'
a
->
string
->
'
a
)
->
'
a
->
in_channel
->
'
a
(* return the content of a file *)
val
file_contents
:
string
->
string
...
...
src/util/util.ml
View file @
e35119d5
...
...
@@ -59,6 +59,11 @@ let option_map_fold f acc x =
let
acc
,
x
=
f
acc
x
in
acc
,
Some
x
(* useful iterator on int *)
let
rec
foldi
f
acc
min
max
=
if
min
>
max
then
acc
else
foldi
f
(
f
acc
min
)
(
succ
min
)
max
let
rec
mapi
f
=
foldi
(
fun
acc
i
->
f
i
::
acc
)
[]
(* useful list combinators *)
let
rev_map_fold_left
f
acc
l
=
...
...
src/util/util.mli
View file @
e35119d5
...
...
@@ -54,6 +54,10 @@ val option_eq : ('a -> 'b -> bool) -> 'a option -> 'b option -> bool
val
option_map_fold
:
(
'
a
->
'
b
->
'
a
*
'
b
)
->
'
a
->
'
b
option
->
'
a
*
'
b
option
(* useful int iterator *)
val
foldi
:
(
'
a
->
int
->
'
a
)
->
'
a
->
int
->
int
->
'
a
val
mapi
:
(
int
->
'
a
)
->
int
->
int
->
'
a
list
(* useful list combinators *)
val
rev_map_fold_left
:
...
...
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