I have a list and I want to check if it's ordered or sorted using a functions
It uses functions:
every
from Map over n consecutive elements inside a listsublist-map
from Map over n consecutive elements inside a list(define (ordered? predicate lst)
(let ((result (sublist-map 2 predicate lst)))
(every identity result)))
Credit: Jakub T. Jankiewicz
(ordered? < '(1 2 3 4))
;; ==> #t
(ordered? < '(1 3 3 4))
;; ==> #f
(ordered? >= '(4 3 3 1))
;; ==> #t