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
054c1a97
Commit
054c1a97
authored
Nov 16, 2011
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
funclang series3: Added assignment 7.
parent
e37f59f9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
funclang-taddeus/series3/ass7.ml
funclang-taddeus/series3/ass7.ml
+50
-0
No files found.
funclang-taddeus/series3/ass7.ml
0 → 100644
View file @
054c1a97
open
List
(* 1 *)
let
rec
nth
l
n
=
match
n
with
|
0
->
hd
l
|
i
when
i
>
0
&&
i
<
(
length
l
)
->
nth
(
tl
l
)
(
i
-
1
)
|
_
->
raise
(
Failure
"list index out of bounds"
)
;;
(* 2 *)
let
heads
l
=
map
hd
l
;;
(* 3 *)
let
zip
l
m
=
let
rec
cut
l
e
=
let
len
=
(
length
l
)
in
if
e
=
len
then
l
else
cut
(
rev
(
tl
(
rev
l
)))
e
in
let
min
a
b
=
if
a
>
b
then
b
else
a
in
let
len
=
min
(
length
l
)
(
length
m
)
in
List
.
combine
(
cut
l
len
)
(
cut
m
len
)
;;
(* 4 *)
let
rec
map
f
l
=
if
length
l
=
0
then
[]
else
(
f
(
hd
l
))
::
(
map
f
(
tl
l
));;
(* 5 *)
let
rec
reduce
f
z
l
=
match
l
with
|
[]
->
z
|
h
::
t
->
f
z
(
reduce
f
h
t
)
;;
(* 6 *)
let
rec
isSublist
l
s
=
match
s
with
|
[]
->
true
|
h
::
t
->
h
=
(
hd
l
)
&&
isSublist
(
tl
l
)
t
;;
(* 7 *)
let
rec
lookup
l
key
=
match
l
with
|
[]
->
raise
(
Failure
"lookup"
)
|
h
::
t
->
let
k
,
v
=
h
in
if
k
=
key
then
v
else
lookup
t
key
;;
(* Challenge *)
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