Which elements in F# are lazy evaluated, which elements are eager evaluated? So far as I know, if "seq" is lazy evaluated, does it mean "list" is eager evaluated? How I prove it? Thanks
F#'s list is eager or lazy evaluated? Or only "seq" is lazy evaluated in F#
Asked Answered
Lists are eagerly evaluated. The answers you got to your question from February 3 demonstrate that. –
Coliseum
For proof you can look at the type definitions of said types. F# list is defined row 1789: github.com/Microsoft/visualfsharp/blob/master/src/fsharp/… –
Disorient
Yes, list is eager. You can try and watch it in Task Manager for example:
#time
let l = List.init 100000000 (fun x -> 0.)
let s = Seq.init 100000000 (fun x -> 0.)
let s2l = s |> Seq.take 10000000 |> Seq.toList
© 2022 - 2024 — McMap. All rights reserved.