Back
ExamFull examExam paper only

23 07 12

Full exam for Principles of Programming Languages in the Computer Engineering degree programme at Politecnico di Milano. The document covers: Principles of Programming Languages, 2012.07.23 Notes: - Total available time: 2h. - You may use any written material you need. - You cannot use computers, phones or laptops during the exam. Exercise 1 (8+8 pts) a) Mushroom Inc. is a software consultant company specialized on

Principles of Programming LanguagesFull exam

Document information

What's included in this study material

Full exam for Principles of Programming Languages in the Computer Engineering degree programme at Politecnico di Milano. The document covers: Principles of Programming Languages, 2012.07.23 Notes: - Total available time: 2h. - You may use any written material you need. - You cannot use computers, phones or laptops during the exam. Exercise 1 (8+8 pts) a) Mushroom Inc. is a software consultant company specialized on

Import quality: text was extracted directly from the original document.

Extracted content from the document

Representative passages recognised in different parts of the material. The full extracted text remains available to search, while this compact preview makes the page easier to read.

Page 1

Principles of Programming Languages, 2012.07.23 Notes: - Total available time: 2h. - You may use any written material you need. - You cannot use computers, phones or laptops during the exam. Exercise 1 (8+8 pts) a) Mushroom Inc. is a software consultant company specialized on functional programming. Its main product is based on “listoid” data structures, that are like lists and contain at least one element. Please define a Haskell type class Listoid that contains all the types having the following operations: • cons: given an element x and a listoid y, return a listoid having x as its first element and y as rest • unit: given an element x, returns a listoid containing x • append: given two listoids, returns the listoid concatenation of them • listoidfirst: returns the first element of the listoid • listoidlast: returns the last element of the listoid • listoidrest: returns all the elements but the first of the input listoid - must return an error if called on a unit listoid LL is one of such data structures: type LL represents lists optimized w.r.t. access to the first and the last element (i.e. accessing them has constant time complexity). Please define LL as an instance of Eq, Listoid, and Show. b) Unfortunately for Mushroom Inc., one of their customers does not like the Haskell language – it prefers C++. In order to avoid losing the customer, Mushroom Inc. has to port LL to C++. While the interface is more or less the same, the C++ version is slightly different from the Haskell one – it must be coded according to C++ idioms. For example, the unit operation can be replaced by a constructor. You are required to build a first prototype of the C++ version of LL. The goal of your project is to test whether its interface matches customer requests, so you can select…

Preview

First page of the document.

First page: 23 07 12