Test if list is ordered by comparator

Problem

I have a list and I want to check if it's ordered or sorted using a functions

Solution

It uses functions:

(define (ordered? predicate lst)
  (let ((result (sublist-map 2 predicate lst)))
    (every identity result)))

Credit: Jakub T. Jankiewicz

Usage

(ordered? < '(1 2 3 4))
;; ==> #t
(ordered? < '(1 3 3 4))
;; ==> #f
(ordered? >= '(4 3 3 1))
;; ==> #t

Back to the Scheme Cookbook