title: Inner Functions With SML NJ
body: <p>I am a complete newbie to sml and am having trouble with the syntax for inner functions.  What I need to do is take a list of a list of ints, average each list, and return a list of reals.  This is the psuedo-ish code I have so far.</p>
  
  <pre><code> fun listAvg [] = 0  
      else (sum (x) div size (x))
  
          fun sum[] = 0
          | sum(head::rest)= head + sum rest;
  
  
          fun size [] = 0
          | size(head::rest) = 1 + size rest;
  
      listAvg([[1,3,6,8,9], [4,2,6,5,1], [9,5,9,7], [5,4], [3,6,4,8]]); 
  </code></pre>
  
  <p>any advice would be greatly appreciated.  Thanks!</p>