Referenced from lesson Method Chaining (Spring, 2021)
You have the following functions defined below (read them carefully!):
fun is-female(r): r["sex"] == "female" end
fun kilograms(r): r["pounds"] / 2.2 end
fun is-heavy(r): r["kilos"] > 25 end
The table t
below represents four animals from the shelter:
name | sex | age | fixed | pounds |
---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Match each Pyret expression (left) to the description of what it does (right). Note: one description might match multiple expressions!
|
1 |
A |
Produces a table containing Toggle, Nori and Maple, with an extra column showing their weight in kilograms |
|
|
2 |
B |
Produces a table containing Maple, Nori and Toggle (in that order) |
|
|
3 |
C |
Produces a table containing only Fritz. |
|
|
4 |
D |
Won’t run: will produce an error |
|
|
5 |
E |
Produces a table containing only Fritz, with two extra columns. |
|
|
6 |
F |
Produces a table containing Maple and Fritz |
These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). Bootstrap:Data Science 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.