;; Common Lisp Script
;; Manoel Vilela

(defun reverse-digits (n)
  (labels ((next (n v)
             (if (zerop n)
                 v
                 (multiple-value-bind (q r)
                     (truncate n 10)
                   (next q (+ (* v 10) r))))))
    (next n 0)))

(defun palindromep (n)
  (= n (reverse-digits n)))

(defun solution()
  (loop for x from 100 to 999
        maximize (loop for y from 100 to 999
                       for p = (* x y)
                       when (palindromep p) maximize p)))

(format t "~a ~%"(solution))


;; Common Lisp Script
;; Manoel Vilela

(defun reverse-digits (n)
  (labels ((next (n v)
             (if (zerop n)
                 v
                 (multiple-value-bind (q r)
                     (truncate n 10)
                   (next q (+ (* v 10) r))))))
    (next n 0)))

(defun palindromep (n)
  (= n (reverse-digits n)))

(defun solution()
  (loop for x from 100 to 999
        for m = (loop for y from 100 to 999
                      for p = (* x y)
                      when (palindromep p) maximize p)
        when (numberp m) maximize m))

(format t "~a ~%"(solution))


Fix a problem with CLISP compilation
Problem004: Fix a problem with CLISP compilation

Sometimes the nested loop may return nil and, at least CLISP, maximize
keyword expansion need be a REAL number.

This doesn't occurs in SBCL. By the way, SBCL execution is much much faster.

CLISP: 10.153 s
SBCL: 0.230 s

Maybe I need change the compiler on ./stats.py later

DestructHub/ProjectEuler,DestructHub/ProjectEuler,DestructHub/ProjectEuler,DestructHub/ProjectEuler,DestructHub/ProjectEuler,DestructHub/ProjectEuler,DestructHub/ProjectEuler,DestructHub/ProjectEuler,DestructHub/ProjectEuler,DestructHub/ProjectEuler,DestructHub/ProjectEuler,DestructHub/ProjectEuler,DestructHub/ProjectEuler,DestructHub/ProjectEuler