Question: In Scheme programming language (preferably using Dr.Racket), write a recursive procedure called isSortedAscendingly? that takes a list of integers as input and returns true if

In Scheme programming language (preferably using Dr.Racket), write a recursive procedure called isSortedAscendingly? that takes a list of integers as input and returns true if the list is sorted ascendingly (in increasing order) and otherwise returns false.

Below are a few examples of inputs/outputs of isSortedAscendingly? procedure.

> (isSortedAscendingly? (list 1 4 8))

#t

> (isSortedAscendingly? (list 1 8 3))

#f

> (isSortedAscendingly? (list 1 8 8))

#t

> (isSortedAscendingly? (list 1))

#t

> (isSortedAscendingly? (list ) )

#t

(list 1) is a list with element 1. Similarly, (list ) is an empty list.

You may find the following procedures useful in your implementation.

; list-length takes a list as a parameter and returns the length of the list.

(define list-length

(lambda (lst)

(if (null? lst)

0

(+ 1 (list-length (cdr lst))))))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!