Skip to content

Instantly share code, notes, and snippets.

@cesare
Created January 7, 2010 18:31
Show Gist options
  • Save cesare/271440 to your computer and use it in GitHub Desktop.
Save cesare/271440 to your computer and use it in GitHub Desktop.
(define (sum-digits n)
(fold + 0 (map (lambda (c) (- (char->integer c) 48)) (string->list (number->string n)))))
(define (display-sum-digits n)
(print (sum-digits n)))
;; inspired by technohippy. see also http://gist.github.com/271049
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment