Referenced from lesson Method Chaining
You have the following functions defined below (read them carefully!):
fun is-fixed(r): r["fixed"] end fun is-young(r): r["age"] < 4 end fun nametag(r): text(r["name"], 20, "red") end fun is-female(r): r["sex"] == "female" end fun kilograms(r): r["pounds"] / 2.2 end fun is-heavy(r): r["kilos"] > 25 end fun is-cat(r): r["species"] == "cat" end fun is-dog(r): r["species"] == "dog" end
Assume that animals-table
is defined, and represents all the animals at the shelter. Solve the word problems below using these functions with filter,
build-table,
and order-by
.
1 |
Create a table of all female cats. |
|
2 |
Create a table of all young, fixed animals. |
|
3 |
Create a table of all female dogs, converting their weight to kilograms. |
|
4 |
Create a table of all heavy dogs. |
|
5 |
Create a table of all young, fixed dogs, sorted from lightest to heaviest. |
|
6 |
Create a table of all fixed, young animals, with an extra column showing images of their nametags. |
|
7 |
Create a table of fixed, female cats, with a column showing images of their nametages, sorted heaviest-to-lightedt by their weight in kilograms. |
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.