LazyList and cons

30 views
Skip to first unread message

Greg Chapman

unread,
May 21, 2013, 6:15:23 PM5/21/13
to FSharp Open Source Community
I've noticed that both the PowerPack and ExtCore implementations of
LazyList wrap a delay around the LazyLists produced by cons and
consDelayed. It seems to me that this is unnecessary, since both
functions are given the value which will be the head of the new
LazyList (so there's no need to delay calculating it). To be specific,
here's some code from the PowerPack:

let lzy f = { status = Delayed f }

let notlazy v = { status = Value v }

let consc x l = CellCons(x,l)
let cons x l = lzy(fun () -> (consc x l))

It seems to me that you could change cons to:

let cons x l = notlazy (consc x l)

without breaking anything or decreasing the laziness. Am I missing
something?


Reply all
Reply to author
Forward
0 new messages