Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uva
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Taddeüs Kroes
uva
Commits
6f9f38c3
Commit
6f9f38c3
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Code cleanup.
parent
2091563a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
funclang-taddeus/series4/ass10.ml
+8
-8
8 additions, 8 deletions
funclang-taddeus/series4/ass10.ml
funclang-taddeus/series6/ass14.ml
+9
-9
9 additions, 9 deletions
funclang-taddeus/series6/ass14.ml
funclang-taddeus/series6/ass16.ml
+10
-12
10 additions, 12 deletions
funclang-taddeus/series6/ass16.ml
with
27 additions
and
29 deletions
funclang-taddeus/series4/ass10.ml
+
8
−
8
View file @
6f9f38c3
...
...
@@ -5,7 +5,7 @@ type bin_op = ArithOp of arith_op | RelOp of rel_op | LogicOp of logic_op
type
mon_op
=
UnaryMinus
|
Negation
type
const
=
BoolConst
of
bool
|
IntConst
of
int
type
expr
=
Enclosure
of
expr
Enclosure
of
expr
|
BinOp
of
expr
*
bin_op
*
expr
|
MonOp
of
mon_op
*
expr
|
Id
of
string
...
...
@@ -15,14 +15,14 @@ type expr =
let
rec
eval_expr
=
let
eval_bin_op
=
let
eval_arith_op
=
function
Plus
->
"+"
|
Plus
->
"+"
|
Minus
->
"-"
|
Times
->
"*"
|
Divide
->
"/"
|
Modulo
->
"mod"
in
let
eval_rel_op
=
function
Eq
->
"="
|
Eq
->
"="
|
Neq
->
"!="
|
Lt
->
"<"
|
Lte
->
"<="
...
...
@@ -30,24 +30,24 @@ let rec eval_expr =
|
Gte
->
">="
in
let
eval_logic_op
=
function
And
->
"&&"
|
And
->
"&&"
|
Or
->
"||"
in
function
ArithOp
op
->
eval_arith_op
(
op
)
|
ArithOp
op
->
eval_arith_op
(
op
)
|
RelOp
op
->
eval_rel_op
(
op
)
|
LogicOp
op
->
eval_logic_op
(
op
)
in
let
eval_mon_op
=
function
UnaryMinus
->
"-"
|
UnaryMinus
->
"-"
|
Negation
->
"!"
in
let
eval_const
=
function
IntConst
i
->
string_of_int
i
|
IntConst
i
->
string_of_int
i
|
BoolConst
b
->
string_of_bool
b
in
function
Enclosure
e
->
"("
^
eval_expr
(
e
)
^
")"
|
Enclosure
e
->
"("
^
eval_expr
(
e
)
^
")"
|
BinOp
(
e1
,
op
,
e2
)
->
eval_expr
(
e1
)
^
" "
^
eval_bin_op
(
op
)
^
" "
^
eval_expr
(
e2
)
|
MonOp
(
op
,
e
)
->
eval_mon_op
(
op
)
^
eval_expr
(
e
)
...
...
This diff is collapsed.
Click to expand it.
funclang-taddeus/series6/ass14.ml
+
9
−
9
View file @
6f9f38c3
...
...
@@ -9,17 +9,17 @@ let emptySet = Set([])
(* Delete an element from a set (if it does not exists in it yet)
* and return the new set with the element *)
let
addElem
elem
set
=
match
set
with
Set
([])
->
Set
([
elem
])
|
Set
([])
->
Set
([
elem
])
|
Set
(
l
)
->
if
List
.
mem
elem
l
then
set
else
Set
(
elem
::
l
)
(* Delete an element from a set (if it exists in it) and return
* the new set without the element *)
let
delElem
elem
set
=
let
rec
delFromList
elem
=
function
[]
->
[]
|
[]
->
[]
|
h
::
t
->
if
h
=
elem
then
t
else
h
::
(
delFromList
elem
t
)
in
match
set
with
Set
([])
->
set
|
Set
([])
->
set
|
Set
(
l
)
->
Set
(
delFromList
elem
l
)
(* Check if an element exists in a set *)
...
...
@@ -28,19 +28,19 @@ let isElem elem = function Set (l) -> List.mem elem l
(* Get the union of sets a and b as a new set *)
let
union
a
b
=
match
a
with
Set
([])
->
b
|
Set
([])
->
b
|
Set
(
la
)
->
match
b
with
Set
([])
->
a
|
Set
([])
->
a
|
Set
(
lb
)
->
Set
(
la
@
List
.
filter
(
fun
e
->
not
(
List
.
mem
e
la
))
lb
)
(* Get the intersection of sets a and b as a new set *)
let
intersection
a
b
=
match
a
with
Set
([])
->
a
|
Set
([])
->
a
|
Set
(
la
)
->
match
b
with
Set
([])
->
b
|
Set
(
lb
)
->
|
Set
([])
->
b
|
Set
(
lb
)
->
let
b_in_a
=
List
.
filter
(
fun
e
->
List
.
mem
e
la
)
lb
in
Set
(
List
.
filter
(
fun
e
->
List
.
mem
e
lb
)
b_in_a
)
...
...
@@ -63,4 +63,4 @@ let b = addElem 9 b;;
let
b
=
addElem
0
b
;;
(* 0, 9, 3, 8, 2 *)
union
a
b
;;
(* 1, 7, 3, 8, 2, 0, 9 *)
intersection
a
b
;;
(* 3, 8, 2 *)
\ No newline at end of file
intersection
a
b
;;
(* 3, 8, 2 *)
This diff is collapsed.
Click to expand it.
funclang-taddeus/series6/ass16.ml
+
10
−
12
View file @
6f9f38c3
module
type
SET
=
sig
module
type
SET
=
sig
type
'
a
set
val
emptySet
:
'
a
set
val
addElem
:
'
a
->
'
a
set
->
'
a
set
...
...
@@ -9,8 +8,7 @@ sig
val
intersection
:
'
a
set
->
'
a
set
->
'
a
set
end
module
Set
:
SET
=
struct
module
Set
:
SET
=
struct
type
'
a
set
=
Set
of
'
a
list
(* Create an empty set *)
...
...
@@ -19,17 +17,17 @@ struct
(* Delete an element from a set (if it does not exists in it yet)
* and return the new set with the element *)
let
addElem
elem
set
=
match
set
with
Set
([])
->
Set
([
elem
])
|
Set
([])
->
Set
([
elem
])
|
Set
(
l
)
->
if
List
.
mem
elem
l
then
set
else
Set
(
elem
::
l
)
(* Delete an element from a set (if it exists in it) and return
* the new set without the element *)
let
delElem
elem
set
=
let
rec
delFromList
elem
=
function
[]
->
[]
|
[]
->
[]
|
h
::
t
->
if
h
=
elem
then
t
else
h
::
(
delFromList
elem
t
)
in
match
set
with
Set
([])
->
set
|
Set
([])
->
set
|
Set
(
l
)
->
Set
(
delFromList
elem
l
)
(* Check if an element exists in a set *)
...
...
@@ -38,19 +36,19 @@ struct
(* Get the union of sets a and b as a new set *)
let
union
a
b
=
match
a
with
Set
([])
->
b
|
Set
([])
->
b
|
Set
(
la
)
->
match
b
with
Set
([])
->
a
|
Set
([])
->
a
|
Set
(
lb
)
->
Set
(
la
@
List
.
filter
(
fun
e
->
not
(
List
.
mem
e
la
))
lb
)
(* Get the intersection of sets a and b as a new set *)
let
intersection
a
b
=
match
a
with
Set
([])
->
a
|
Set
([])
->
a
|
Set
(
la
)
->
match
b
with
Set
([])
->
b
|
Set
(
lb
)
->
|
Set
([])
->
b
|
Set
(
lb
)
->
let
b_in_a
=
List
.
filter
(
fun
e
->
List
.
mem
e
la
)
lb
in
Set
(
List
.
filter
(
fun
e
->
List
.
mem
e
lb
)
b_in_a
)
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