Referenced from lesson Contracts (Spring, 2021)

Type this line of code into the interactions area and hit "Enter":

triangle​(​50, "solid", "red"​)

1

What is the name of this function?

2

What did the expression evaluate to?

3

How many arguments does triangle expect?

4

What data type does the triangle function produce?
(Numbers? Strings? Booleans?)

Catching Bugs

The following lines of code are all BUGGY! Read the code and the error messages to identify the mistake.

5 triangle(20, "solid" "red")

Pyret didn’t understand your program around

triangle(20, "solid" "red")

Can you spot the mistake?

6 triangle(20, "solid")

This application expression errored:

triangle(20, "solid")

2 arguments were passed to the operator. The operator evaluated to a function accepting 3 parameters. An application expression expects the number of parameters and arguments to be the same.

Can you spot the mistake?

7 triangle(20, 10, "solid", "red")

This application expression errored:

triangle(20, 10, "solid", "red")`

4 arguments were passed to the operator. The operator evaluated to a function accepting 3 parameters. An application expression expects the number of parameters and arguments to be the same.

Can you spot the mistake?

8 triangle (20, "solid", "red")

Pyret thinks this code is probably a function call:

triangle (20, "solid", "red")

Function calls must not have space between the function expression and the arguments.

Can you spot the mistake?

These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). CCbadge Bootstrap:Algebra by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.