title: Understanding foldl in ML
body: <p>I need to write a function that takes a list of strings and finds the largest string in the list. The catch is it needs to iterate through the list using List.foldl and cannot use recursive calls except for those in the library function of List,foldl. </p>
  
  <p>I wrote</p>
  
  <pre><code>fun longest_string1(xs)= 
  case xs of 
  [] =&gt; ""  
  | x::xs' =&gt; List.foldl((fn (s,x) =&gt; if String.size s &gt; String.size x then s else x) "" x,)
  </code></pre>
  
  <p>with my interpretation being as follows:<br><br>
  -take in xs, if xs is empty return an empty string<br><br>
  -otherwise for the first item of xs call List.foldl<br><br> 
  -List.foldl passes in an anonymous function that checks the length of s, which should represent the accumulator against the head item of the list. <br><br>-Set the initial accumulator to be the empty string and the initial compare value to be the head of the initial list passed in by the higher order function</p>
  
  <p>However, it does not type check. </p>
  
  <p>I think my issue is in the understanding of the List.foldl function itself and how exactly it reads in its parameters.   Can someone please provide some clarification? </p>