RACKET a) Write a recursive function (gen-list start end). This function will generate a list of consecutive...

50.1K

Verified Solution

Question

Programming

RACKET

a) Write a recursive function (gen-list startend). This function will generate a list of consecutive integers,from start to end. If start > end then an empty list isgenerated. For example: (gen-list 1 5) ---> (1 2 3 4 5)

b) write a recursive function pair-sum? that takes an integersequence as generated by the gen-list function in exercise 4 above.This function tests whether any two adjacent values in the givenlist sum to the given val. For example,

   (pair-sum? '(1 2 3) 3) ---> #t since 1+2=3.Similarly,

   (pair-sum? (gen-list 1 100) 1000) ---> #f sinceno two adjacent integers in the range 1 to 100 can sum to 1000.

You must use recursion, and not iteration. Pleaseinclude explanation thanks.

Answer & Explanation Solved by verified expert
3.9 Ratings (610 Votes)
Solution a Previous Version suppose startn and endN void genlistint n int N This genlist will generatelist of consecutive integers from start    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students