forked from jmchapman/ITT8060.2013
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoursework1.fsx
More file actions
56 lines (39 loc) · 2.01 KB
/
coursework1.fsx
File metadata and controls
56 lines (39 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
(*
ITT8060 -- Advanced Programming 2013
Department of Computer Science
Tallinn University of Technology
------------------------------------
Coursework 1: Basic operations on lists
------------------------------------
Name:
Student ID:
------------------------------------
Answer the questions below. You answers to questions 1--8 should be
correct F# code written after the question. This file is an F#
script file, it should be possible to load the whole file at
once. If you can't then you have introduced a syntax error
somewhere.
This coursework will be graded. Please send the completed coursework
including your name and student ID in the comments by e-mail to
itt8060@cs.ttu.ee by Friday, September 20.
*)
// 1. Make an empty list of generic type.
// 2. Make an empty list of type 'int list' (or list<int>).
// 3. Make a three element list called 'cities' containing pairs of
// city names (string) and populations (int).
// 4. Write a function 'filterOutVillages' to filter out cities with
// less than 1000 inhabitants from your list. It should not use the
// filter function from the library. The function should use pattern
// matching and recursion.
// 5. Test the function 'filterOutVillages' on your list 'cities'.
// 6. Calculuate the average population of your list of cities. The
// function should use pattern matching and recursion.
// 7. Write function 'allcaps' which capitalizes the names of cities in a
// list of cities. Hint: "abc".ToUpper ()
// 8. Write a function that first filters out villages and then
// capitalizes names. Use the operation '|>' in your answer.
// 9. Convert 'cities' into a pair of a list of city names and a list
// of city populations. Use a function that you saw in lecture 2.
// 10. Create a list of pairs of lower case ascii characters (a-z) and
// their ascii codes. e.g. for the letter 'a' the pair would be ('a',97)
// Hint: you can use a function you saw in lecture 2 to help.