我試圖編寫一個程序,它獲取一個整數作爲參數,如果數字是一個迴文,則返回true,否則返回false,並且似乎是在更改全局參數的值時出現問題內部功能塊。有界變量和作用域
(define index 0)
(define (palindrome? x)
(if (= (lenght x) 1)
#t
(if (last_equal_first x)
(palindrome? (remove x))
#f)))
(define (lenght x)
(define index **(+ index 1))**
(if (= (modulo x (ten_power index)) x)
index
(lenght x)))
(define (last_equal_first x)
(if (= (modulo x 10) (modulo x (/ (ten_power (lenght x)) 10)))
#t
#f))
我想知道我能做些什麼吧 的感謝!