title: laziness in action? (Haskell)
body: <p>In chapter 6 of <em>Learn You a Haskell</em>, the following function is introduced:</p>
  
  <pre><code>zipWith' :: (a -&gt; b -&gt; c) -&gt; [a] -&gt; [b] -&gt; [c]
  zipWith' _ [] _ = []
  zipWith' _ _ [] = []
  zipWith' f (x:xs) (y:ys) = f x y : zipWith' f xs ys
  </code></pre>
  
  <p>The author gives a couple examples of its use which I found easy enough to follow. Then this one:</p>
  
  <pre><code>ghci&gt; zipWith' (zipWith' (*)) [[1,2,3],[3,5,6],[2,3,4]] [[3,2,2],[3,4,5],[5,4,3]]
  </code></pre>
  
  <p>Which outputs <code>[[3,4,6],[9,20,30],[10,12,12]]</code></p>
  
  <p>Is this an example of lazy evaluation? I tried to translate zipWith' into Scheme (see below). I got it working with the "easy" examples, but not the last one, which makes me think that Haskell's laziness might be making the difference.</p>
  
  <pre><code>(define zipWith
    (lambda (f listA listB)
      (cond
        ((null? listA) (quote ()))
        ((null? listB) (quote ()))
        (else (cons (f (car listA) (car listB)) (zipWith f (cdr listA) (cdr listB)))))))
  </code></pre>