Referenced from lesson Piecewise Functions
Alice has hired you to improve some code used at the restaurant. The code we’ll be improving on is shown below.
Read through the code line-by-line with your partner before writing down your observations in the tables below.
cost :: String -> Number # given an item, produce the cost of that item fun cost(item): ask: | string-equal(item, "hamburger") then: 6.00 | string-equal(item, "onion rings") then: 3.50 | string-equal(item, "fried tofu") then: 5.25 | string-equal(item, "pie") then: 2.25 | otherwise: "Sorry, that’s not on the menu!" end end
1) I notice…
|
2) I wonder…
|
3) Familiar things I see in the code:
|
4) Unfamiliar things I see in the code:
|
These materials were developed partly through support of the National Science Foundation,
(awards 1042210, 1535276, 1648684, and 1738598).
Bootstrap:Algebra by Emmanuel Schanzer, Jen Poole, Ed Campos Jr, Flannery Denny, and Dorai Sitaram
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.