title: SML - lists and recursion
body: <p>I have list in SML, which contains members from datatype <code>"expr"</code> (list "b").
  I also have function <code>"What"</code>, which it's arguments are only from dayatype <code>"expr"</code>.
  Now I have problem in the next code:</p>
  
  <pre><code>datatype expr = K of string| Number2 of expr * (expr list);
  datatype number = Number1 of string | Number3 of int;
  What....
  | What (Number2 (t,[]))= Number3(0)::What(t)
  | What (Number2 (y,(a::b)) = append (What(a), What(b));
  </code></pre>
  
  <p>The error occurred because b is list of <code>expr</code>, and the function <code>What</code> got only "<code>expr</code>" and not "<code>expr list</code>". All I want to do is to check all the members is <code>"b"</code>, and make a new list - which member is from datatype <code>"number"</code>.
  I tried to use <code>map function</code>, but it didn't help (see the marks here: <a href="https://stackoverflow.com/questions/8009873/sml-unbound-variable-or-constructor">SML - unbound variable or constructor</a>).</p>
  
  <p>Any idea? There is another way to do it, without using map? I stack on it for a day..</p>