Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
POTTIER Francois
alphaLib
Commits
f98c7001
Commit
f98c7001
authored
Feb 02, 2017
by
POTTIER Francois
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New functions [domain] and [codomain].
parent
e1360eba
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
src/Atom.ml
src/Atom.ml
+18
-2
src/Atom.mli
src/Atom.mli
+10
-1
No files found.
src/Atom.ml
View file @
f98c7001
...
...
@@ -139,6 +139,11 @@ module Set = struct
include
Set
.
Make
(
Order
)
(* A disjointness test. *)
let
disjoint
xs
ys
=
is_empty
(
inter
xs
ys
)
(* Disjoint union. *)
exception
NonDisjointUnion
of
atom
...
...
@@ -194,5 +199,16 @@ module Set = struct
end
module
Map
=
Map
.
Make
(
Order
)
module
Map
=
struct
include
Map
.
Make
(
Order
)
(* This is O(nlog n), whereas in principle O(n) is possible.
The abstraction barrier in OCaml's [Set] module hinders us. *)
let
domain
m
=
fold
(
fun
a
_
accu
->
Set
.
add
a
accu
)
m
Set
.
empty
let
codomain
f
m
=
fold
(
fun
_
v
accu
->
Set
.
union
(
f
v
)
accu
)
m
Set
.
empty
end
src/Atom.mli
View file @
f98c7001
...
...
@@ -28,6 +28,8 @@ val hash: atom -> int
module
Set
:
sig
include
Set
.
S
with
type
elt
=
atom
val
disjoint
:
t
->
t
->
bool
(* Disjoint union. *)
exception
NonDisjointUnion
of
atom
...
...
@@ -55,4 +57,11 @@ end
(* Maps. *)
module
Map
:
Map
.
S
with
type
key
=
atom
module
Map
:
sig
include
Map
.
S
with
type
key
=
atom
val
domain
:
'
a
t
->
Set
.
t
val
codomain
:
(
'
a
->
Set
.
t
)
->
'
a
t
->
Set
.
t
end
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