Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SICP: Scheme Quetion. (a) The exponent function can be defined as exp (x , n) exp (x, n-1) , if n > 0 , if

SICP: Scheme Quetion.

image text in transcribedimage text in transcribed

(a) The exponent function can be defined as exp (x , n) exp (x, n-1) , if n > 0 , if n 0 = x * i. Write a Scheme function which implements exp as defined above. Your function must generate a Recursive process. [4 marks] ii. Write another version of exp which generates an Iterative process [5 marks] (b) Write a Scheme procedure, called enum-downfrom, that takes a positive integer n and returns a list of integers from n down to zero inclusive. So, for example: (enum-downfrom 4) returns the list (4 3 2 1 0) [3 marks] (c) Write a Scheme procedure, called drop, which takes a positive integer parameter n and a list parameter ls and returns a list consisting of all but the first n elements of 1s. If 1s is less than n elements long then drop should just return the empty list. So, for example: (drop 3 Clist 3 4567 8)) will return the list (6 7 8) and: (drop 10 (list 1 2 3)) will return the empty list: () [4 marks] (d) Write a Scheme procedure called sfunc which takes in two procedural values: f and g and returns a procedure which takes a value x and returns: fx) + g(x). So, for example, given the following definitions (define (square x) (* x x)) (define (inc x) (+ x 1)) (define si (sfunc square inc)) The call: (si 4) - (16 5) 21 [4 marks]

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

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions

Question

3. Discuss the process of behavior modeling training.

Answered: 1 week ago