Referenced from lesson Defining Table Functions

For the word problems below, assume dog-row, cat-row, young-row and old-row are already defined as data rows.

Directions: Define a function called is-cat, which consumes a Row of the animals table and computes whether the animal is a cat.

Contract and Purpose Statement

Every contract has three parts…​

# is-cat::Row->Boolean

# Consumes an animal, and computes whether the species equals "cat"

Examples

Write some examples, then circle and label what changes…​

examples:

__is-cat (dog-row)is ___________________________

________ (_______)is ___________________________

end

Definition

Write the definition, giving variable names to all your input values…​

fun is-cat(r):

__r["species"] == "cat"

end

Directions: Define a function called is-young, which consumes a Row of the animals table and computes whether it is less than four years old.

Contract and Purpose Statement

Every contract has three parts…​

# ________::___->_______

# ________________________________________________________________

Examples

Write some examples, then circle and label what changes…​

examples:

__________ (_________)is ____________________

__________ (_______)is __________________

end

Definition

Write the definition, giving variable names to all your input values…​

fun ________(_):

______________

end

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