Lecture 18: Built-in abstractions
This assignment is due on Tuesday, October 18 at 11:59pm. Submit it using Handin as assignment lecture18.
1 Built-in abstractions
What is the name of the function?
How many inputs does the function take? What are their names?
How many inputs does the signature take? What are their names?
; Exercise 1 ; The function ??? has ??? inputs, called ??? and ???. ; Its signature has ??? inputs, called ??? and ???.
Design a function filter-without-a that takes a list of strings as input and returns the list of all the given strings that do not contain the letter "a". Hint: What is X? The built-in functions not and string-contains? will help.
Design a function filter-x<y that takes a list of Posns as input and returns the list of all the given Posns whose X coordinate is less than their Y coordinate. Hint: What is X? Design a helper function that follows the template for processing a Posn.
Design a function add-to-all that adds a given number to every number in a given list. Hint: What is X and what is Y? Use either local or lambda.
Remember the function move-invaders from Lecture 14: Built-in structures? It takes and returns a [ListOf Posn]. It increases each Y coordinate by 1. Design it again, still named move-invaders. Hint: What is X and what is Y? Design a helper function that follows the template for processing a Posn.
The code written in the videos above is available for your reference. To download it, don’t use “Save Page As” or “Save As”; use “Save Link As” or “Download Linked File” in your Web browser. If you can’t find the command, try right-clicking or two-finger-tapping or long-pressing.
2 Combining built-in abstractions
Exercise 6. Design a function lengths-without-e that takes a list of strings and returns a list of numbers, which are the lengths of those strings that do not contain the letter "e". Use map and filter, rather than following the function template for processing a list.