Computer Science in Algebra
The Design Recipe
Writing intelligent functions, intelligently
Vocab
Roadmap to Function-land
Design Recipe Step 1
purple-star: Number -> Image
Define a function ’purple-star’ that takes in the size of the star and returns an outlined, purple star of the given size.
Design Recipe Step 1
50less: Number -> Number
Write a function called “50less” that takes in a number, and returns a number that is 50 less.
Design Recipe Step 2a
50less(45) = 45 - 50
Write an example of what your function should produce, given some input (in this case 45)
Design Recipe Step 2b
50less(70) = 70 - 50
Write another example of what your function should produce, given some input (in this case 70)
Design Recipe Step 2c
50less(45) = 45 - 50
50less(70) = 70 - 50
Compare the two examples to see what changes
Design Recipe Step 3
Write a function called “50less” that takes in a number, and returns a number that is 50 less.
50less(x) = x - 50
Design Recipe Step 1
purple-star: Number -> Image
Define a function ’purple-star’ that takes in the size of the star and returns an solid, purple star of the given size.
Design Recipe Step 2a
purple-star(45) = star(45, “solid”, “purple”)
Write an example of what your function should produce, given some input (in this case 45)
Design Recipe Step 2b
purple-star(120) = star(120, “solid”, “purple”)
Write another example of what your function should produce, given some input (in this case 120)
Design Recipe Step 2c
Compare the two examples
size
Design Recipe Step 3
Define a function ’purple-star’ that takes in the size of the star and returns an solid, purple star of the given size.
Collaborative Design
Each member of your group will take on one role:
Use the Collaborative Design Recipe Worksheets to complete the following problems
Collaborative Design