Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
595764af
Commit
595764af
authored
Oct 05, 2007
by
Pietro Abate
Browse files
[r2005-06-17 15:42:03 by afrisch] Empty log message
Original author: afrisch Date: 2005-06-17 15:42:04+00:00
parent
a8c712ec
Changes
2
Hide whitespace changes
Inline
Side-by-side
misc/imap.ml
View file @
595764af
...
...
@@ -66,26 +66,25 @@ let rec find_aux t (i : int) low high =
if
(
low
>=
high
)
then
low
else
let
m
=
((
low
+
high
)
lsr
1
)
lor
1
in
if
i
<
get
t
m
then
find_aux
t
i
low
(
m
-
2
)
if
i
<
get
t
m
then
find_aux
t
i
low
(
m
-
2
)
else
find_aux
t
i
m
high
let
find
(
t
:
'
a
t
)
i
:
'
a
=
if
t
==
empty
then
raise
Not_found
;
let
j
=
find_aux
t
i
1
(
get
t
0
)
in
let
j
=
find_aux
t
i
1
(
get
t
0
-
2
)
in
if
(
get
t
j
==
i
)
then
(
Obj
.
magic
get
t
(
succ
j
))
else
raise
Not_found
let
find_default
t
def
i
=
if
t
==
empty
then
def
else
let
j
=
find_aux
t
i
1
(
get
t
0
)
in
let
j
=
find_aux
t
i
1
(
get
t
0
-
2
)
in
if
(
get
t
j
==
i
)
then
(
Obj
.
magic
get
t
(
succ
j
))
else
def
let
find_lower
(
t
:
'
a
t
)
i
:
'
a
=
assert
(
t
!=
empty
);
Obj
.
magic
get
t
(
succ
(
find_aux
t
i
1
(
get
t
0
)))
Obj
.
magic
get
t
(
succ
(
find_aux
t
i
1
(
get
t
0
-
2
)))
let
merge
(
t1
:
'
a
t
)
(
t2
:
'
a
t
)
=
if
t1
==
empty
then
t2
else
if
t2
==
empty
then
t1
...
...
@@ -192,7 +191,7 @@ let hash f t =
let
remove
t
i
=
if
t
==
empty
then
t
else
let
j
=
find_aux
t
i
1
(
get
t
0
)
in
let
j
=
find_aux
t
i
1
(
get
t
0
-
2
)
in
if
(
get
t
j
!=
i
)
then
t
else
let
n
=
get
t
0
-
2
in
...
...
types/atoms.ml
View file @
595764af
...
...
@@ -90,19 +90,29 @@ let get_map (ns,x) m =
module
IntSet
=
Set
.
Make
(
struct
type
t
=
int
let
compare
(
x
:
int
)
y
=
Pervasives
.
compare
x
y
end
)
let
create
def
l
=
match
def
with
|
None
->
(
match
l
with
(
i
,
x
)
::
rest
->
Imap
.
create_default
x
(
Array
.
of_list
rest
)
|
[]
->
assert
false
)
|
Some
d
->
Imap
.
create_default
d
(
Array
.
of_list
l
)
let
mk_map
l
=
let
l
=
List
.
filter
(
fun
(
t
,_
)
->
not
(
is_empty
t
))
l
in
if
l
=
[]
then
Imap
.
empty
else
let
all_ns
=
ref
IntSet
.
empty
in
let
def
=
ref
Imap
.
creat
e
in
let
def
=
ref
Non
e
in
List
.
iter
(
function
(
s
,
x
)
->
match
get
s
with
|
`Finite
s
->
List
.
iter
(
fun
(
ns
,_
)
->
all_ns
:=
IntSet
.
add
ns
!
all_ns
)
s
|
`Cofinite
_
->
def
:=
Imap
.
create_default
(
Imap
.
create_default
x
[
||
])
|
`Cofinite
_
->
def
:=
Some
(
Imap
.
create_default
x
[
||
])
)
l
;
let
one_ns
ns
=
let
def
=
ref
Imap
.
creat
e
in
let
def
=
ref
Non
e
in
let
t
=
List
.
fold_left
(
fun
accu
(
s
,
y
)
->
...
...
@@ -110,18 +120,12 @@ let mk_map l =
|
SymbolSet
.
Finite
syms
->
List
.
fold_left
(
fun
accu
x
->
(
x
,
y
)
::
accu
)
accu
syms
|
SymbolSet
.
Cofinite
syms
->
def
:=
Imap
.
create_default
y
;
accu
)
def
:=
Some
y
;
accu
)
[]
l
in
(
!
def
)
(
Array
.
of_list
t
)
create
(
!
def
)
t
in
let
t
=
List
.
fold_left
(
fun
accu
ns
->
(
ns
,
one_ns
ns
)
::
accu
)
[]
(
IntSet
.
elements
!
all_ns
)
in
(
!
def
)
(
Array
.
of_list
t
)
create
(
!
def
)
t
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