Starting from:

$30

PPL222-Assignment 2 Solved

General Instructions
Submit your answers to the theoretical questions in a pdf file called idl_id2.pdf and your code for programming questions inside the provided q2.13, and L31-ast.ts, q3.ts, q4.ts files of the src folder. ZIP those files together (including the pdf file, and only those files) into a file called idl_id2.zip. Make sure that your code abides by the Design By Contract methodology.

Do not send assignment related questions by e-mail, use the forum instead. For any administrative issues (milu'im/extensions/etc) please open a request ticket in the Student Requests system.

You are provided with the templates ex2.zip.

Unpack the template files inside a folder. From the command line in that folder, invoke npm

1 nstall, and work on the files in that directory, preferably working in the Visual Studio Code

IDE (refer to the Useful Links). In order to run the tests, run npm test from the command line.

Important: Do not add any extra libraries and do not change the provided package.json and tsconfig.json configuration files. The graders will use the exact provided files. If you find any missing necessary libraries, please let us know.

Question 1: Theoretical Questions 
1.1 Is a function-body with multiple expressions required in a pure functional programming? In which type of languages is it useful? 

 

QI.2
a. Why are special forms required in programming languages? Why can't we simply define them as primitive operators? Give an example 

             'PJ                ecpec;a

            'O'J ÖO         
  ア。'、・、ア。卿e。同みrと~ノツ,c)ア卩  なをイ戸'しぞ″。乙 々以。国(1) 2) 

PA .ロp / ,んらぬ(りx ・)アノID「

              づ,、〆/。~ ~                            JJpnゾ、0んどや工

                                          谷り0     - u      ~ゾ

b. Can the logical operation 'or' be defined as a primitive operator, 0「must it be defined as a special form? Refer in your answer to the option Of shortcut semantics. 

 

) ) L)ゝ

 プて 

QI. 3 What is a syntactic abbreviation? Give two examples 
 

 

 乢/眠。リ( 

 

QI.4
a. What is the value of the following L3 program? Explain.

(define x 1)

(let ( (x 5)

y)

  4

 

 (24 -O
C

 -HL/'QRJI)  Joe C' O A/c              D ve0

b.  Read about let* here.

What is the value of the following program? Explain.

 (define x 1) (let* ( (x 5)      

y)

                          p'/J1 PJ

 Pf l X - T (d k -A 

  ( II DA".) 

c.  Annotate lexical addresses in the given expression

(define x 2 )

(define y 5)

 (let

(f (lambda (z) 

 (let*

(f (lambda (z) 

d.  Define the let* expression in section c above as an equivalent let expression  

e.  Define the let* expression in section c above as an equivalent application expression

(with no let) 

More products