PPL222 Homework 2 Solved

30.00 $

Category:

Description

Rate this product

 

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?

  1. Why are special forms required in programming languages? Why can’t we simply define

them as primitive operators? Give an example

  1. Can the logical operation ‘or’ be defined as a primitive operator, or must it be defined as

a special form? Refer in your answer to the option of shortcut semantics.

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

QI.4

  1. What is the value of the following L3 program? Explain. [2 points]

(define x 1)

(let ( (x 5)

y)

  1. Read about let* here.

What is the value of the following program? Explain. [2 points]

(define x

(let* ( (x

y)

1)

5)

  1. Annotate lexical addresses in the given expression [6 points]

(define x 2)

(define y 5)

(let

(f (Lambda (z)

(let*

(f (lambda (z)

  1. Define the let* expression in section c above as an equivalent let expression [3 points]
  2. Define the let* expression in section c above as an equivalent application expression

(with no let) [3 points]

 

  • hw2-wzmxvd.zip