Question: This function is written for you | # ( define ( replace - all - tail lst id with ) ( replace - all -
This function is written for you
#
define replacealltail lst id with
replaceallhelper lst id with
#
replaceallhelper lst id with acc list?
lst: list?
A list of values
id: symbol?
A value to be replaced in the list
with: symbol?
A value that will take the place of id in lst
acc: list?
An accumulator
Helper function to replacealltail.
#
definematch replaceallhelper lst id with acc
id with acc
; you may need more patterns
cons first rest id with accif equal first idreplaceallhelper rest id with list acc withreplaceallhelper rest id with list acc first
module test
testequal? "replaceall: empty list"
replaceall a b
testequal? "replaceall: some replacement"
replaceall b a c aa b
b b c b
replacealltail: some replacement
FAILURE
name: checkequal?
location: wlab.rkt::
actual:
expected: b b c b
why is the code failing the second test
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
