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
Get step-by-step solutions from verified subject matter experts
