title: ML list typing when converting char list to int list
body: <p>I've been having an issue with converting a character list to an int list. My goal is to basically take a number such as 325 and have it return a list of [3,2,5]. What I've done so far is take the number and then convert it to a string, which then gets exploded to a char array. I then want to convert each char to a respective int. When I map my char list into fn c => Char.ord(c) the char list becomes an ?.int list, which prevents me from doing operations(+,-) on it. I'm new to ML and don't have a strong grasp of its type system but it seems odd to me. </p>
  
  <p>Here's the code:</p>
  
  <pre><code>open IntInf;
  
  fun fact_helper (0, r : int) = r
    | fact_helper (n : int, r : int) = fact_helper (n-1, n*r);
  
  fun factorial n:int = fact_helper (n, 1);
  
  fun num_to_digits n =  
      let val digits_as_chars = explode (IntInf.toString n);
      in map (fn c =&gt; (Char.ord c)) digits_as_chars
      end;
  </code></pre>
  
  <p>Ideally I'd like to be able to do <code>fn c =&gt; (Char.ord c) - 48</code> in my mapping function to get the true digit value. I've done something similar before and it worked then but not now and I'm unsure why I'm getting the <em>?.int list</em> type. Original problem can be found as <a href="https://projecteuler.net/problem=20" rel="nofollow">Project Euler problem 20</a>.</p>