Open My Function Starter File on your computer. Sign in and save a copy.

Add Examples and Define Your Function

1 Notice how we’ve defined two images (pink-tri and yellow-rec) at the top of the starter file. These are the images we will use to test out our functions. On line 6, type in a third image definition of your choosing. What function will you use?

2 In the Interactions Area, translate and type your Circle of Evaluation into code - but instead of using the word "image" as your input, type in one of the defined values.

3 If you get an error, or if you are not getting the result that you expected, try again until it works. Describe one adjustment that you made.

4 Once the code is working how you’d like, you’re mostly done creating your first example! In the definitions area, type my-function( ). Inside the parentheses, provide the input you just used. Next, type in the word is, and then paste in the code you just entered.

  • Repeat this process to create two additional examples with different inputs.

  • Be sure to format your examples to make them more readable. (If you need help with formatting, you can refer to the Functions Starter File.)

5 After entering your examples, hit run to confirm that Pyret likes your examples. You should see the message, "Looks shipshape, all 3 tests passed, mate!"

6 Define my-function in Pyret. (If you don’t remember how to define a function, you can refer to the Functions Starter File.)

Peer Review

7 Swap papers with a partner. You’ll also want to have your partner’s Pyret program open. Write your name on the line so that your teacher knows who is reviewing this function.

8 Did your partner write 3 different and correctly formatted examples? If not, what was the issue?

9 When you hit run, do you see the message, "Looks shipshape, all 3 tests passed, mate!"? If not, work with your partner to find and fix the problem. Describe what was wrong, if there was a problem.

Publish and Submit Your Program

10 Save your program. Select "File", then "Save a Copy." Go to "Publish", and copy the link that appears. Follow your teacher’s instructions for submitting the link.

These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, 1738598, 2031479, and 1501927). CCbadge Bootstrap 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.