On 24 May 2011 13:41, Johannes Waldmann <waldm...@imn.htwk-leipzig.de> wrote:
> I could just store the length of the list - as an additional argument > to the "Cons" constructor that is automatically initialized on construction > (and you never need to change it later, since Haskell objects > are "immutable", in the words of Java programmers) > > In Haskell, the reason for not doing this (besides simplicity, and inertia) > actually is (I think) laziness: you don't want to evaluate > the "length" field of the second argument of the "cons" prematurely. Neither OCaml nor PLT Scheme cache the length or they didn't a year of two ago when someone asked this question on the Haskell Beginners list and I checked the respective source trees. As the PLT Scheme list was implemented in C at the time (maybe it still is?) I was a bit surprised by this. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe