Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uva
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
uva
Commits
9dcd50cc
Commit
9dcd50cc
authored
Dec 05, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
funclang series5: Indent cleanup.
parent
810556ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
funclang-taddeus/series5/ass11.ml
funclang-taddeus/series5/ass11.ml
+4
-4
No files found.
funclang-taddeus/series5/ass11.ml
View file @
9dcd50cc
...
...
@@ -4,7 +4,7 @@ type 'a rbtree = Leaf | Node of 'a * color * 'a rbtree * 'a rbtree
(* Balance a node by matching it against the four cases and returning a new,
* well-structured node *)
let
balance_node
node
=
match
node
with
Node
(
z
,
Black
,
Node
(
y
,
Red
,
Node
(
x
,
Red
,
a
,
b
)
,
c
)
,
d
)
Node
(
z
,
Black
,
Node
(
y
,
Red
,
Node
(
x
,
Red
,
a
,
b
)
,
c
)
,
d
)
|
Node
(
z
,
Black
,
Node
(
x
,
Red
,
a
,
Node
(
y
,
Red
,
b
,
c
))
,
d
)
|
Node
(
x
,
Black
,
a
,
Node
(
z
,
Red
,
Node
(
y
,
Red
,
b
,
c
)
,
d
))
|
Node
(
x
,
Black
,
a
,
Node
(
y
,
Red
,
b
,
Node
(
z
,
Red
,
c
,
d
)))
->
...
...
@@ -16,7 +16,7 @@ let balance_node node = match node with
let
insert
tree
value
=
let
rec
insert_in_tree
=
function
(* Insert new Node at leaf position *)
Leaf
->
Node
(
value
,
Red
,
Leaf
,
Leaf
)
Leaf
->
Node
(
value
,
Red
,
Leaf
,
Leaf
)
|
Node
(
v
,
color
,
left
,
right
)
->
if
value
=
v
then
(* Value has already been inserted *)
...
...
@@ -30,12 +30,12 @@ let insert tree value =
in
match
insert_in_tree
tree
with
(* Color the root black *)
Node
(
v
,
_
,
left
,
right
)
->
Node
(
v
,
Black
,
left
,
right
)
Node
(
v
,
_
,
left
,
right
)
->
Node
(
v
,
Black
,
left
,
right
)
|
Leaf
->
raise
(
Failure
"Error during insertion"
)
(* 'a -> 'a rbtree -> bool *)
let
rec
lookup
value
=
function
Leaf
->
false
Leaf
->
false
|
Node
(
v
,
_
,
left
,
right
)
->
v
=
value
||
(
if
value
<
v
then
lookup
value
left
else
lookup
value
right
)
...
...
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