Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the functions in one scheme file. Thanks in advance! For these problems, you must use pure functional scheme. That is You may not use

image text in transcribed

Write the functions in one scheme file. Thanks in advance!

For these problems, you must use pure functional scheme. That is You may not use a functions like set! whose name ends with'" .You may not use do. All repetition must be via explicit recursion or the recursion implicit in map or similar functions. .You may, however, use define - in fact you must use it. You may define additional helper functions Be sure to test your definitions using some implementation of the "R5RS" scheme standard, preferably the one in Racket - see Resources > Scheme > scheme-links.html for a discussion of how to get it. (It is what I have been using in lecture.) If you use the Racket implementation of scheme, be sure that the language is set to R5RS the name "R5RS" should appear at the bottom left corner of the window, and not something like "advanced student" or "Determine language from source 1. Define (i.e. write) the function (echo lst). This function doubles each top-level element of list lst. E.g., (echo '(a b c)) returns (aabbcc). (echo '(a (b c))) returns (a a (b c) (b c)) 2. Define the function (echo-lots lst n). (echo-lots '(a (b c)) 3) returns (aa a (b c) (b c) (b c)), that is, it is like echo but it repeats each element of lst n times 3. Define the function (echo-all Ist) which is a deep version of echo. (echo-all '(a (b c)) should return (a a (b bcc)(b b c c) 4. Define the function nth. (nth i lst) returns the ith element of lst. E.g., (nth 0 '(a b c)) returns a, and (nth 1 '(a (b c) d) returns (b c). You may assume that 0si (key2>...) whose elements are two-element lists ( ), whose first element is a key and whose second element is the associated value.) assoc-all returns a list of the data associated with elements of keys by a-list. E.g. (assoc-all '(a d c d) '((a apple)(b boy)(c (cat cow)(d dog)) returns (apple dog (cat cow) dog). Use map. Note that you can't simply use assoc as one of the arguments to map; you need to use a lambda expression. 6. Define a scheme function filter which takes two arguments: a function fn and a list Ist. Filter should return a list consisting of those elements of lst for which the fn returns true. E.g., the value of (filter even? (3 4 678)) should be (4 6 8)) (The function even? is a built-in function in scheme which returns #t if its argument is even and #fif odd.) 7. Define a scheme function (filter-out-er fn) which returns a function of one argument. This argument must be a list, and the function returned must filter that list using (not fn) as its filter E.g., ((filter-out-er even) (3 4 6 7 8) should return (3 7)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions