---
title: Drill 6 Solution
tags: Drills-F20, 2020
---
# Drill 6 Solution
## Question 1
Fill in the blanks in the following lambda expression. The lambda should take two Numbers as inputs and return a Number that's the product of the two input Numbers.
```
<a>(<b>): x * y <c>
```
a: ____
b: ____
c: ____
::: spoiler Answer
a: `lam`
b: `x, y` or `y, x`
c: `end`
:::
## Question 2
Can all lambda expressions be rewritten as functions?
( ) Yes
( ) No
::: spoiler Answer
(X) Yes
( ) No
You can think of lambda expressions as short-hand for one-line functions.
:::
## Question 3
What will happen if we write the following in the definitions window and then click 'Run'?
Try to answer without using Pyret.
```
num = 5
square = lam(n): n * n end
square(num)
```
( ) 25 will be output in the interactions window
( ) Nothing
( ) "The declaration of the identifier named num shadows a previous declaration of an identifier also named num"
( ) Error: "The identifier 'num' is unbound"
( ) Error: "The declaration of the identifier named square shadows a previous declaration of an identifier also named square"
::: spoiler Answer
(X) 25 will be output in the interactions window
( ) Nothing
( ) "The declaration of the identifier named num shadows a previous declaration of an identifier also named num"
( ) Error: "The identifier 'num' is unbound"
( ) Error: "The declaration of the identifier named square shadows a previous declaration of an identifier also named square"
Since `square(num)` is 25.
:::
## Question 4
What concept from this week of class is *least clear* to you?