Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (extract-nth-digit a n current)
- (if (= current n)
- (modulo a 10)
- (extract-nth-digit (quotient a 10) n (+ 1 current))))
- (define (length a)
- (if (and (< 0 a) (< a 10))
- 1
- (+ 1 (length (/ a 10)))))
- (define (middle-digit a)
- (if (even? (length a))
- -1
- (extract-nth-digit a (ceiling (/ (length a) 2)) 1)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement