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
d2387098
Commit
d2387098
authored
Dec 04, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
funclang series5: Added test file for ass12.
parent
d793bb9e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
0 deletions
+61
-0
funclang-taddeus/series5/test_ass12.ml
funclang-taddeus/series5/test_ass12.ml
+61
-0
No files found.
funclang-taddeus/series5/test_ass12.ml
0 → 100644
View file @
d2387098
#
use
"ass12.ml"
;;
(* let a = 1 in b *)
print_endline
(
expr2string
(
Let
(
"a"
,
(
Num
1
)
,
(
Var
"b"
))));;
(* a + 3 *)
print_endline
(
expr2string
(
BinopAp
(
Add
,
Var
"a"
,
Num
3
)));;
(* -a *)
print_endline
(
expr2string
(
MonopAp
(
Neg
,
Var
"a"
)));;
let
show_freevars
e
=
let
free
=
match
freevars
e
with
[]
->
""
|
[
x
]
->
x
|
h
::
t
->
List
.
fold_left
(
fun
a
b
->
a
^
", "
^
b
)
h
t
in
print_endline
(
"
\n
Free variables in:
\n
"
^
(
expr2string
e
)
^
"
\n
are: ["
^
free
^
"]"
)
;;
(* Write the expressions of assignment series 1 in our data types *)
let
u
=
Var
"u"
in
let
c
=
Var
"c"
in
let
bcc
=
l
"b"
(
l
"c"
c
)
in
let
a
=
Var
"a"
in
let
aaa
=
l
"a"
(
app
a
a
)
in
let
aaa_aaa
=
app
aaa
aaa
in
let
v
=
Var
"v"
in
let
uvw
=
l
"u"
(
app
(
l
"v"
(
l
"w"
v
))
(
l
"a"
a
))
in
let
1
a
=
(
app
(
app
bcc
aaa_aaa
)
uvw
);;
let
v
=
Var
"v"
in
let
w
=
Var
"w"
in
let
uvw
=
l
"u"
(
l
"v"
(
l
"w"
(
app
(
app
u
v
)
w
)))
in
let
x
=
Var
"x"
in
let
y
=
Var
"y"
in
let
z
=
Var
"z"
in
let
xyz
=
l
"x"
(
l
"y"
(
l
"z"
(
app
x
(
app
y
z
))))
in
let
a
=
Var
"a"
in
let
b
=
Var
"b"
in
let
c
=
Var
"c"
in
let
1
b
=
(
app
(
app
(
app
(
app
uvw
xyz
)
a
)
b
)
c
);;
(* [a] *)
show_freevars
(
Fun
(
"b"
,
(
BinopAp
(
Add
,
Var
"a"
,
Num
3
))));;
(* [] *)
show_freevars
(
Fun
(
"a"
,
(
BinopAp
(
Add
,
Var
"a"
,
Num
3
))));;
let
l
arg
body
=
Fun
(
arg
,
body
);;
let
app
f
e
=
FunAp
(
f
,
e
);;
(* [] *)
show_freevars
1
a
;;
(* [a, b, c] *)
show_freevars
1
b
;;
(* fun u -> fun w -> fun a -> a *)
(*print_endline (expr2string (subs 1b));;*)
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