title: How to calculate the sum of a digits of a number in Scheme?
body: <p>I want to calculate the sum of digits of a number in Scheme.  It should work like this:</p>
  
  <pre><code>&gt;(sum-of-digits 123)
   6
  </code></pre>
  
  <p>My idea is to transform the number <code>123</code> to string <code>"123"</code> and then transform it to a list <code>'(1 2 3)</code> and then use <code>(apply + '(1 2 3))</code> to get <code>6</code>.</p>
  
  <p>but it's unfortunately not working like I imagined.</p>
  
  <pre><code>&gt;(string-&gt;list(number-&gt;string 123))
  '(#\1 #\2 #\3)
  </code></pre>
  
  <p>Apparently <code>'(#\1 #\2 #\3)</code> is not same as <code>'(1 2 3)</code>... because I'm using language <code>racket</code> under DrRacket, so I can not use the function like <code>char-&gt;digit</code>. </p>
  
  <p>Can anyone help me fix this?</p>