Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write recursive Dr Racket functions to do the following. The functions should work on all types of lists( not just simple lists of atoms). Document

Write recursive Dr Racket functions to do the following. The functions should work on all types of lists( not just simple lists of atoms). Document (via direct Dr Racket screens/outputs) both your code and the results of running the test cases.

a) Count how many times an item (atom) appears on a list.

Minimum test cases:

(count 3 '(1 5 6 7 8 3 2 3 )) returns 2

(count dog '(cat bird cat dog frog)) returns 1

(count a '(a(a b ) (c (b c)) ((a))b) returns 3

(count 3 '(1)) returns 0

(count none '()) returns 0

b) Check if a list has duplicate values.

Minimum test cases:

(duplicates '(1 5 6 7 8 3 2 3 )) returns true

(duplicates '(cat bird pony dog frog)) returns false

(duplicates '(a(a b) (c(b c)) (a b)) returns true

(duplicates '((a) (a b) (c (b c))a b)) returns false

(duplicates '(1)) returns false

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

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago