4

Does F# even have lazy evaluation?

mcandre
  • 22,868
  • 20
  • 88
  • 147
  • 9
    It seems like [a lazy question](http://msdn.microsoft.com/library/ee353813.aspx) :P. – pad Nov 09 '12 at 15:33

1 Answers1

9

F# is not lazy-by-default (a la Haskell). But explicit laziness is available. See Lazy Computations on MSDN.

Daniel
  • 47,404
  • 11
  • 101
  • 179
  • Thank you. Could you provide an example in F# of a lazy prime number sequence, and how to take `n` primes from it? – mcandre Nov 09 '12 at 15:31
  • 3
    The `Lazy` type computes a single result. You want a sequence (`IEnumerable<'T>`). Take a look at [this question](http://stackoverflow.com/q/4629734/162396) for some examples. – Daniel Nov 09 '12 at 15:35