The goal is to check if a non-negative number's digits are in increasing order.
Here is my code:
(define (in-order-iter num)
(define (aux num-left result-so-far)
(cond ((equal? result-so-far #f) #f)
((< num-left 10) result-so-far)
((aux (quotient num-left 10) (< (modulo (quotient num-left 10) 10)(modulo num-left 10))))))
(aux num #t))
(in-order-iter 321)
The worst part is, when I decide to use (display result-so-far), I get the answer I want (which is #f), but my function won't return it. If I decide to use (in-order-iter 123), it does return #t.
When I test
(< (modulo (quotient 321 10) 10)(modulo 321 10)))
alone, it does return #f, so it should change result-so-far to #f.
Why is this happening to me?!
Edit: By the way, I can do this function recursively and it works:
(define (in-order-recur num)
(if (> num 10)
(if (< (modulo (quotient num 10) 10) (modulo num 10))
(in-order-recur (quotient num 10))
#f)
#t))
(in-order-recur 100000)