# PLQ #8Done on:   Tuesday, November 9th

## Question 1 @ 2021-11-09 18:27

What can you say about a language that fulfils the following test:

(test (map (+ 2) '(1 2 3)) => '(3 4 5))

• It cannot be compiled

• It is dynamically scoped

• It is Schlac

• It is Schlac, extended by all of the encodings we’ve seen in class

• It cannot be a statically typed language (like `#lang pl`)

• It is an auto-curried language

## Question 2 @ 2021-11-09 18:30

Can you write a `blank` definition in Racket so the following test succeeds?

(test (* blank blank) => 660)

• Yes, `(define blank (sqrt 660))`

• No; `sqrt` would produce a floating point, so it’ll return `660.0`

• Yes, using exact rationals

• Yes, using mutation

## Question 3 @ 2021-11-09 18:33

How would you write a `blank` definition in Racket so the following test succeeds?

(test (* (blank) (blank)) => 660)

• (define (blank)
(let ([b (box #f)])
(set-box! b (not (unbox b)))
(if (unbox b) 1 660)))
• (define blank
(let ([b (box #f)])
(lambda ()
(set-box! b (not (unbox b)))
(if (unbox b) 1 660))))
• (define (blank)
(let ([b (box #f)])
(lambda ()
(set-box! b (not (unbox b)))
(if (unbox b) 1 660))))
• (define (blank)
(let ([b (box #t)])
(define result (if (unbox b) 660 1))
(set-box! b #f)
result))
• (define blank
(let ([b (box #t)])
(lambda ()
(define result (if (unbox b) 660 1))
(set-box! b #f)
result)))
• (define (blank)
(let ([b (box #t)])
(lambda ()
(define result (if (unbox b) 660 1))
(set-box! b #f)
result)))

## Question 4 @ 2021-11-09 18:39

Consider a function of type `A -> B`, and another function of type `T -> T` .

Which of the following condition will make the first function be a subtype of the second? That is, which of these will make

A -> B  ⊆ T -> T

?

• `A ⊆ T`
• `T ⊆ A`
• `B ⊆ T`
• `T ⊆ B`