Open your copy of the Table Functions Starter File and click "Run".
Filtering Rows
1 What does filter(shapes-table, is-red)
evaluate to? Describe the value you get back below.
2 What does filter(shapes-table, is-polygon)
evaluate to? Describe the value you get back below.
3 Write the code to generate a table of only triangles.
4 At the bottom of the Definitions Area, define triangles
by writing triangles = filter(shapes-table, is-triangle)
. Click "Run" and evaluate triangles
in the Interactions Area.
5 Define reds
to be a table of only red shapes.
6 What do the contracts for is-red
, is-polygon
, and is-triangle
have in common?
7 Find the Contract for filter
on the Contracts Page. If you’re working with a printed workbook, the contracts pages are included in the back. Explain how filter
uses the two inputs specified in the Domain.
8 What happens if you evaluate filter(shapes-table, lookup-name)
? Why?
Building Columns
9 What does build-column(shapes-table, "red", is-red)
evaluate to?
10 What does build-column(shapes-table, "img", draw-shape)
evaluate to?
11 Find the Contract for build-column
on the Contracts Page. If you’re working with a printed workbook, the contracts pages are included in the back.Explain how build-column
uses the three inputs specified in the Domain.
Define your own table!
★ In the Definitions Area, define a table of your own using filter
or build-column
. Add a comment to describe what’s in it!
These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, 1738598, 2031479, and 1501927). 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.