Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You must implement three functions from each of the List, . In some cases, these functions are already defined in Racket (DrRacket). To avoid confusion,

You must implement three functions from each of the List, . In some cases, these functions are already defined in Racket (DrRacket). To avoid confusion, you can name yours differently, for example myreverse for reverse. Or you can just override the built-in definition. You may use other builtin functions, such as if, cond, car (first), cdr (rest), and cons in your functions. But you may not, of course, use a builtin function in your answer for that same function. (Racket is a type of language in Lisp)

List Functions

You must implement at least three of these list functions.

1. Append two lists (append (1 3 x a) (4 2 b)) => (1 3 x a 4 2 b)

2. Reverse a list (reverse (a b c d)) => (d c b a)

3. Map a function to every element in a list (define (add3 x) (+ 3 x)) (map add3 (1 2 3 4)) => (4 5 6 7)

4. Remove duplicates from a list (nub (1 1 2 4 1 2 5)) => (1 2 4 5)

5. Fold-left (arguments are: initial value, function, list) (fold 10 - (1 3 2)) => 4 3

6. Filter (define (lessthan3 x) (< x 3)) (filter lessthan3 (1 4 5 2 1 6)) => (1 2 1)

7. Merge two sorted lists (merge (1 3 4 7) (2 3 6)) => (1 2 3 3 4 6 7)

8. Add an element to the end of a list. Cool hint: try using reverse (addtoend d (a b c)) => (a b c d)

9. Index of (indexof a (b c a d)) => 2 (indexof a (b c d f)) => -1

10. Remove-all (remove-all a (b a c a a d a)) => (b c d)

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

Step: 3

blur-text-image

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

1st Edition

1597496251, 978-1597496254

More Books

Students also viewed these Databases questions

Question

What are some career development methods?

Answered: 1 week ago

Question

1. How do most insects respire ?

Answered: 1 week ago

Question

Who is known as the father of the indian constitution?

Answered: 1 week ago

Question

1.explain evaporation ?

Answered: 1 week ago