Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Fall 2008
Exercise 2
The Basics Revisited Introduction
In this exercise we will delve deeper inside the world of Oz, gaining experience and practice with some more advanced programming concepts. You should try to solve these tasks using declarative programming techniques only (that is, no explicit state, no cells).
Hint: use your solution to task 1 and 2. {MatrixMult [[1 0 2] [~1 3 1]] [[3 1] [2 1] [1 0]]} % returns [[5 1] [4 2]] {MatrixMult [[4 7] [3 1]] [[8 1] [1 7]]} % returns [[39 53] [25 10]]
Task 6: Merge
Write a function {Merge L1 L2 L3} that merges three lists. The second input list should start where the rst input list ends. The third input list should start where the second input list ends. Be sure to account for cases where the input lists are empty. For example, {Merge [1 2 3] [4] [5 6]} % returns [1 2 3 4 5 6] {Merge [6 5 4] nil [3 2 1]} % returns [6 5 4 3 2 1] {Merge nil [1] nil} % returns [1]
Task 7: Sort
Write a function that takes a list as input and sorts it. You may choose whatever sorting algorithm you want. Remember that characters are represented by their corresponding character codes. For example, {Sort [5 4 2 6]} % returns [2 4 5 6] {Sort [b a t]} % returns [a b t]