Question: 9. Here is a function called deleteall that strips out all occurrences of a value in a given list. The call to the function:
9. Here is a function called "deleteall" that strips out all occurrences of a value in a given list. The call to the function: (deleteall 0 '(4030201)) results in the list (4 3 2 1). (define (deleteall atm list) (cond ( (NULL? list) ' ( ) ) ( (EQ? atm (CAR list)) ( ELSE (CONS (CAR list) (deleteall atm (CDR list))) (deleteall atm (CDR list)))) )) Write a recursive Scheme procedure called "tally" that counts the number of occurrences of a value in a given list. Do not use a counter variable, but let the function result in the desired count. For example, the value of (tally 0 ' (4030201)) will be 3. The procedure will be very similar to deleteall.
Step by Step Solution
There are 3 Steps involved in it
define tally atm list cond null list 0 atm car list 1 tally atm cdr list else tally a... View full answer
Get step-by-step solutions from verified subject matter experts
