Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I am programming in Scheme, I am trying to make a function where you take a list of numbers, reverse the list, throw out the
I am programming in Scheme, I am trying to make a function where you take a list of numbers, reverse the list, throw out the negative numbers and summation the nonnegatives. Here is my code:
define sum n
if eq n
n sum n
define ReverseEm elems
if null elems
append ReverseEm cdr elems
list car elems
define nonNegative num
if num
num
define JustDoIt lst
if nonNegative ReverseEm sum lst
If I run JustDoIt it say Illformed special form: if
The correct output should be
Because summation of is gets thrown out, gets thrown out, the list gets reversed: I feel I am close, but I can't get the form right in scheme because I am unfimiliar with it can you help me
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started