title: Haskell: using foldl to cascade functions
body: <p>So here I have singleton list  </p>
  
  <pre><code>[([("*" "1"),("/" "5"),("*" "10")],"")]
  </code></pre>
  
  <p>I have to take the <code>fst $ head</code> of it which is  </p>
  
  <pre><code>[("*" "1"),("/" "5"),("*" "10")]
  </code></pre>
  
  <p>Combine it with a simple string <code>"5"</code>, and transform it into </p>
  
  <pre><code>(("*" "10") (("/" "5") (("* "1") "5")))
  </code></pre>
  
  <p>I know this would involve either <code>foldl</code> or <code>foldr</code>, but I just cant get it right...</p>
  
  <p>This is for a parser project, I could post all the background information, but that would be too much.</p>
  
  <p>Thanks in advance.</p>
  
  <p>EDIT:</p>
  
  <p>this is Haskell btw</p>
  
  <p>Ah, figured this one out  </p>
  
  <pre><code>&gt; prods =  do left &lt;- term       
  &gt;             right &lt;- many (mul `mplus` div `mplus` mod)
  &gt;             return (foldl (\l r -&gt; Call r l) left right)
  </code></pre>
  
  <p>Don't read too much into it, basically it takes the <code>5 * 1 / 5 *10</code> and convert them into <code>((* 10) ((/ 5) ((* 1) 5)))</code></p>