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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started