Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use downloaded software DrRacket, SCHEME program .scm , R5RS language from source, use SCHEME program .scm, language R5RS [2 marks] Create a function (repeat x

use downloaded software DrRacket, SCHEME program .scm , R5RS language from source, use SCHEME program .scm, language R5RS

  1. [2 marks] Create a function (repeat x n) that returns a list that contains n copies of the value x. E.g.:
     (repeat 'a 5)  (a a a a a) 
  2. [2 marks] Create a function (alternate list1 list2) that creates a list by alternating elements from the two given input lists. E.g.:
     (alternate '(0 0 0 0) '(1 1 1 1 1 1))  (0 1 0 1 0 1 0 1 1 1) 
  3. [2 marks] Create a procedure (count x L) that returns the number of instances of the value x in the list L. E.g.:
     (count 3 '(1 4 3 6 2 3 3 1 4 3 5 7))  4 (count 'b '(4 b a 3 2 c b 1 b 2 d a))  3 
  4. [4 marks] Create a procedure (mode L) that returns the most common value in the list L. Hint: this question is asking that you find the item with the largest count. In the case of a tie return the value closest to the front of the list (ie the first one encountered). E.g.,
     (mode '(a b a c a d d a b c a b))  a (mode '(2 b a 3 2 c b 1 b 2 d a))  2 
  5. [5 marks] Create a procedure (decreasing L) that returns a list of all of the consecutive decreasing subseqeuences in the input list. E.g.,
     (decreasing '(3 6 8 9 7 4 8 6 3))  ((9 7 4) (7 4) (8 6 3) (6 3)) (decreasing '(7 6 5 4 8 5 2 5 1 5 2 1))  ((7 6 5 4)(6 5 4)(5 4)(8 5 2)(5 2)(5 1)(5 2 1)(2 1)) (decreasing '(1 2 3 4 5))  ()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

1. Explain the 2nd world war. 2. Who is the father of history?

Answered: 1 week ago