Chapter 2: Problem 20
\begin{aligned} &\text { The procedures }+, * \text {, and list take arbitrary numbers of arguments. One way to } \\ &\text { define such procedures is to use define with dotted-tail notation. In a procedure } \\ &\text { definition, a parameter list that has a dot before the last parameter name indicates } \\ &\text { that, when the procedure is called, the initial parameters (if any) will have as } \\ &\text { values the initial arguments, as usual, but the final parameter's value will be a } \\ &\text { list of any remaining arguments. For instance, given the definition } \\\ &\text { (define (f } \mathrm{x} \mathrm{y} \cdot \mathrm{z} \text { ) }\langle\text { body }\rangle \text { ) } \\ &\text { the procedure } \mathrm{f} \text { can be called with two or more arguments. If we evaluate } \\ &\text { (f } 123456 \text { ) } \\ &\text { then in the body of } \mathrm{f}, \mathrm{x} \text { will be } 1, \mathrm{y} \text { will be } 2, \text { and } \mathrm{z} \text { will be the list }(3456) \text {. } \\ &\text { Given the definition } \\ &\text { (def ine (g. w) }\langle\text { body }\rangle \text { ) } \\ &\text { the procedure g can be called with zero or more arguments. If we evaluate } \\ &\text { (g } 123456 \text { ) } \\ &\text { then in the body of g, w will be the list ( } 1234566 \text { ). } \\\ &\text { Use this notation to write a procedure same-parity that takes one or more } \\ &\text { integers and returns a list of all the arguments that have the same even-odd parity } \\ &\text { as the first argument. For example, } \\ &\text { (same-parity } 1234567 \text { ) } \\ &(1357) \\ &\text { (same-parity } 234567 \text { ) } \\ &(246) \end{aligned}
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.