title: Writing a C# version of Haskell infinite Fibonacci series function
body: <p><strong>Note:</strong> The point of this question is more from a curiosity perspective. I want to know out of curiosity whether it is even possible to <em>transliterate</em> the Haskell implementation into a functional C# equivalent.</p>
  
  <p>So I've been <a href="http://learnyouahaskell.com/" rel="nofollow">learning myself Haskell for great good</a>, and while solving <a href="http://en.wikipedia.org/wiki/Project_Euler" rel="nofollow">Project Euler</a> problems I ran into this beautiful Haskell <a href="https://en.wikipedia.org/wiki/Fibonacci_number" rel="nofollow">Fibonacci</a> implementation:</p>
  
  <pre><code>fibs :: [Integer]
  fibs = 1:1:zipWith (+) fibs (tail fibs)
  </code></pre>
  
  <p>Of course I was tempted to write a C# version like this, so:</p>
  
  <ol>
  <li><p>If I do this:</p>
  
  <pre><code>IEnumerable&lt;int&gt; fibs =
      Enumerable.Zip(Enumerable.Concat(new int[] { 1, 1 }, fibs),
                                                         //^^error
                                            fibs.Skip(1), (f, s) =&gt; f + s);
  </code></pre>
  
  <p>The error says use of unassigned local variable <code>fibs</code>.</p></li>
  <li><p>So I went slightly imperative, while this compiles...</p>
  
  <pre><code>public static IEnumerable&lt;int&gt; Get()
  {
      return Enumerable.Zip(Enumerable.Concat(new int[] { 1, 1 }, Get()),
                                            Get().Skip(1), (f, s) =&gt; f + s);
  }
  </code></pre>
  
  <p>It breaks with a stack overflow exception! So I came here..</p></li>
  </ol>
  
  <p>Questions:</p>
  
  <ol>
  <li>Can anyone think of a functional C# equivalent that works?</li>
  <li>I'd like some insight into why my solutions don't work.</li>
  </ol>