You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Conceptually, a LazyList<'T> contains a head of type 'T and a tail of type Lazy<LazyList<'T>>. Strangely, there is no direct way to construct such a lazy list using the current API. The best can be done is LazyList.consDelayed head (fun () -> tail.Value), which is unnecessarily wasteful.
I suggest a new function for creating such a list: LazyList.consLazy (head : <'T>) (tail : Lazy<LazyList<'T>>).
For bonus points, also provide an infix operator that can be used for clarity. I suggest something like (@).
Desired result
I should be able to create an infinite list of 1's like this: let rec ones = 1 @ lazy ones.
Known workarounds
consDelayed can be used but it is inelegant and wasteful.
The text was updated successfully, but these errors were encountered:
Description
Conceptually, a
LazyList<'T>
contains a head of type'T
and a tail of typeLazy<LazyList<'T>>
. Strangely, there is no direct way to construct such a lazy list using the current API. The best can be done isLazyList.consDelayed head (fun () -> tail.Value)
, which is unnecessarily wasteful.I suggest a new function for creating such a list:
LazyList.consLazy (head : <'T>) (tail : Lazy<LazyList<'T>>)
.For bonus points, also provide an infix operator that can be used for clarity. I suggest something like
(@)
.Desired result
I should be able to create an infinite list of 1's like this:
let rec ones = 1 @ lazy ones
.Known workarounds
consDelayed
can be used but it is inelegant and wasteful.The text was updated successfully, but these errors were encountered: