1 (require (only (lib "list.ss") sort))
\r
3 (define (numbers a b)
\r
5 (else (cons a (numbers (add1 a) b)))))
\r
7 (define (cross l1 l2)
\r
10 (append (map (lambda (x)
\r
13 (cross (cdr l1) l2))))
\r
15 (define 3-digit-numbers (numbers 111 999))
\r
17 (define sorted-pairs (reverse (sort (cross 3-digit-numbers
\r
20 (< (* (car x) (cdr x))
\r
21 (* (car y) (cdr y)))))))
\r
23 (define (palindrome? s)
\r
25 (list->string (reverse (string->list s)))))
\r
27 (let loop ((pairs sorted-pairs))
\r
30 (let* ((pair (car pairs))
\r
31 (num (number->string (* (caar pairs)
\r
33 (if (palindrome? num)
\r
35 (loop (cdr pairs))))))
\r