shithub: sl

Download patch

ref: cdd7c7d616c2eaad0ece771a0c3c08ebe332d432
parent: 3512e8bf86d1b5387bcd7543e85c50e147db4bf1
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sat Jan 4 19:09:56 EST 2025

>=, <=: let loop

--- a/system.lsp
+++ b/system.lsp
@@ -176,11 +176,10 @@
 (define (> a . rest)
   "Return #t if the arguments are in strictly decreasing order (previous
 one is greater than the next one)."
-  (define (f a rest)
+  (let loop ((a a) (rest rest))
     (or (null? rest)
         (and (< (car rest) a)
-             (f (car rest) (cdr rest)))))
-  (f a rest))
+             (loop (car rest) (cdr rest))))))
 (define-macro (> a . rest)
   `(< ,@(reverse! rest) ,a))
 
@@ -187,22 +186,20 @@
 (define (<= a . rest)
   "Return #t if the arguments are in non-decreasing order (previous
 one is less than or equal to the next one)."
-  (define (f a rest)
-    (unless (null? rest)
-      (or (< (car rest) a)
-          (nan? a)
-          (f (car rest) (cdr rest)))))
-  (not (f a rest)))
+  (let loop ((a a) (rest rest))
+    (or (null? rest)
+        (unless (or (< (car rest) a)
+                    (nan? a))
+          (loop (car rest) (cdr rest))))))
 
 (define (>= a . rest)
   "Return #t if the arguments are in non-increasing order (previous
 one is greater than or equal to the next one)."
-  (define (f a rest)
-    (unless (null? rest)
-      (or (< a (car rest))
-          (nan? a)
-          (f (car rest) (cdr rest)))))
-  (not (f a rest)))
+  (let loop ((a a) (rest rest))
+    (or (null? rest)
+        (unless (or (< a (car rest))
+                    (nan? a))
+          (loop (car rest) (cdr rest))))))
 
 (define-macro (/= a . rest)
   "Return #t if not all arguments are equal. Shorthand for (not (= …))."