Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider a list where every element is a nested list of length 2. The first element of each nested list is either a 0 or

Consider a list where every element is a nested list of length 2. The first element of each nested list is either a 0 or a 1. The second element of each nested list is some integer. As an example:

'((0 1) (1 2) (1 3) (0 4) (0 3))

For the purposes of this question, lets call the first element of each nested list thekey,and the second element of the nested lists thevalue. In racket, implement a function, count-by-cat, that takes such a list as input and yields a two element list where

  • the first element is the sum of the values of all nested lists with 0 as the key, and
  • the second element is the sum of the values of all nested lists with 1 as the key

It may be helpful to create helper functions. Also do not forget about map and filter.

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

Design Operation And Evaluation Of Mobile Communications

Authors: Gavriel Salvendy ,June Wei

1st Edition

3030770249, 978-3030770242

More Books

Students also viewed these Programming questions