Commits

Taylor Venable committed aad198c

Marc Feeley's speed improvements.

Comments (0)

Files changed (1)

+;; (declare (standard-bindings) (extended-bindings) (block) (not safe) (fixnum))
+;;
 ;; Writing this in C roughly doubles the speed of Gambit's code.
 ;;
 ;; (c-declare #<<c-declare-end
 ;; }
 ;; c-declare-end
 ;; )
-;;
+;; 
 ;; (define c-sum-of-squares (c-lambda (char-string) int "sum_of_squares"))
 ;; (define sum-of-squares
 ;;   (lambda (n)
 ;;     (c-sum-of-squares (number->string n))))
+;;
+;; (define sum-of-squares
+;;   (lambda (n)
+;;     (let loop ((n n) (s 0))
+;;       (if (> n 0)
+;;         (loop (quotient n 10) (+ s (square (modulo n 10))))
+;;         s))))
+;; 
+;; (define square
+;;   (lambda (x)
+;;     (* x x)))
 
 (define sum-of-squares
   (lambda (n)