Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a recursive Racket function update-if that takes two functions, f and g, and a list xs as parameters and evaluates to a list. f

Write a recursive Racket function "update-if" that takes two functions, f and g, and a list xs as parameters and evaluates to a list. f will be a function that takes one parameter and checks if the input if even... and then returns true or false. g will be a function that takes one parameter and evaluates to some output (for example if you pass in add1 then g(2) should be 3.. if you passed in the function sub1 then g(2) should be 1. The result of update-if should be a list of items such that if x is in xs and (f x) is true, then (g x) is in the list. The output list's elements should keep the input list's items in the same relative order.

For example (update-if even? add1 '(1 2 3 4)) should evaluate to '(3 5) because 2 and 4 make even? true and add1 turns 2 and 4 into 3 and 5.

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

The Core Ios Developer S Cookbook Core Recipes For Programmers

Authors: Erica Sadun ,Rich Wardwell

5th Edition

0321948106, 978-0321948106

More Books

Students also viewed these Programming questions

Question

What is the evidence that Earths outer core is liquid?

Answered: 1 week ago

Question

price ceilings are illegal in the United States true or false

Answered: 1 week ago