Question: Scheme Programming (R5RS) or Dialect of LISP // Functional Programming can be done in DrRacket. ;;; Function sorted?: list of numbers -> boolean ;;; Returns

Scheme Programming (R5RS) or Dialect of LISP // Functional Programming

can be done in DrRacket.

;;; Function sorted?: list of numbers -> boolean

;;; Returns #t if the elements in the list are in ascending order and #f otherwise

For example:

> (sorted? '(3 8 9 1)) -> #f

> (sorted? '(3 8 5 2)) -> #f

> (sorted? '(3 9 12)) -> #t

> (sorted? '(3)) -> #t

> (sorted? '()) -> #f

What I got so far is wrong below:

(define (sorted? lst) (if (null? lst) #t (cons (and (lst car) (lst cdr)))))

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!