Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alphaLib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
POTTIER Francois
alphaLib
Commits
f98c7001
Commit
f98c7001
authored
8 years ago
by
POTTIER Francois
Browse files
Options
Downloads
Patches
Plain Diff
New functions [domain] and [codomain].
parent
e1360eba
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Atom.ml
+18
-2
18 additions, 2 deletions
src/Atom.ml
src/Atom.mli
+10
-1
10 additions, 1 deletion
src/Atom.mli
with
28 additions
and
3 deletions
src/Atom.ml
+
18
−
2
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
This diff is collapsed.
Click to expand it.
src/Atom.mli
+
10
−
1
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment