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

The table t below represents four animals from the shelter:

name sex age fixed pounds

"Toggle"

"female"

3

true

48

"Fritz"

"male"

4

true

92

"Nori"

"female"

6

true

35.3

"Maple"

"female"

3

true

51.6

Match each Pyret expression (left) to the description of what it does (right).

t.order-by("age", true)

1

A

Produces a table containing only Toggle and Maple

t.filter(is-fixed)

2

B

Produces a table of only young, fixed animals

t.build-column("sticker", nametag)

3

C

Produces a table, sorted youngest-to-oldest

t.filter(is-young)

4

D

Produces a table with an extra column, named "sticker"

t.filter(is-young)
  .filter(is-fixed)

5

E

Produces a table containing Maple and Toggle, in that order

t.filter(is-young)
  .order-by("pounds", false)

6

F

Produces a table containing the same four animals

t.build-column("label", nametag)
  .order-by("age", true)

7

G

Won’t run: will produce an error

t.order-by("agee", false)

8

H

Produces a table with an extra "label" column, sorted youngest-to-oldest

These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). CCbadge Bootstrap:Data Science by Emmanuel Schanzer, Nancy Pfenning, Emma Youndtsmith, Jennifer Poole, Shriram Krishnamurthi, Joe Politz, Ben Lerner, Flannery Denny, and Dorai Sitaram with help from Eric Allatta and Joy Straub is licensed under a Creative Commons 4.0 Unported License. Based on a work at www.BootstrapWorld.org. Permissions beyond the scope of this license may be available by contacting schanzer@BootstrapWorld.org.