Question: Create a function in the scheme programming language that will check if any two numbers in a list are equal to a given integer and
Create a function in the scheme programming language that will check if any two numbers in a list are equal to a given integer and return the a list that contains the two numbers. Ex: given the list '(1 2 3 4 5 6) and the integer 9, the function should return a list like '(4 5).
Please utilize and finish the code below which includes two functions to do the given task. The mainFunction and helperFunction should both call eachother (backtracking)
(define mainFunction
(lambda (sum theList)
(cond (BASE CASE) ( (SOME CONDITION) (helperFunction sum (car theList (cdr theList)))
(else (RECURSION)))))
(define helperFunction
(lambda (sum n theList) ;; n: n is the the current element in theList that we are trying to add with another number in the list
(cond (BASE CASE) ( (SOME CONDITION) (RECURSION))
(else (RECURSION)))))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
