← Indietro
EsameEsame completoTesto d’esame

06 07 12

Esame completo di Principles of Programming Languages per il corso di Computer Engineering presso Politecnico di Milano. Materiale proveniente dall’archivio storico Studwiz e classificato per la consultazione online.

Principles of Programming LanguagesEsame completo

Informazioni sul documento

Cosa trovi in questo materiale

Esame completo di Principles of Programming Languages per il corso di Computer Engineering presso Politecnico di Milano. Materiale proveniente dall’archivio storico Studwiz e classificato per la consultazione online.

Qualità dell’importazione: il testo è stato estratto direttamente dal documento originale.

Contenuti estratti dal documento

Passaggi rappresentativi riconosciuti nelle diverse parti del materiale. Il testo completo resta presente nella pagina per la ricerca, mentre l’anteprima compatta rende più semplice la lettura.

Pagina 1

Principles of Programming Languages, 2012.07.06 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 a) Define an iterator for lists in Scheme, such that calling it returns an element. When there are no more elements, it returns symbol <<end>>. E.g. (define il (make-iter '(1 2))) (il) returns 1 (il) returns 2 (il) returns <<end>> b) Define an analogous iterator for vectors. c) Define a new construct "for/in" which iterates on lists or vectors. E.g. (for x in '(1 2 3) (display x)) shows 123 (for x in '#(c a s a) (display x)(display ".")) shows c.a.s.a. Exercise 2 Consider the operation revmap which reverses a list and then performs a map: i.e. revmap (*2) [1,2,3] is [6,4,1] a) Define a Prolog implementation of revmap traversing the list only once. (HINT: use as many parameters as needed) b) Define a pure and strict Haskell implementation of revmap, possibly with linear time complexity (assuming that the mapped function has constant time complexity) and traversing the list only once. Exercise 3 You are currently working on the Padi project, a graphical interface for entry-level users. The performance team has observed several major slowdowns in some applications using Padi. It seems that the problem is due to some memory leaks related to the usage of classes ScrollBar and TextPane. In order to identify the problem, it is needed to track memory allocation and de- allocation of instances of those classes. You have to modify the C++ sources of Padi in order to: • every time an instance of ScrollBar or TextPane is allocated on the heap, the address and the size of the allocate block is be printed on standard error • every time a memory block holding an instance of ScrollBar or…

Anteprima

Prima pagina del documento.

Prima pagina: 06 07 12