fsprojects / fsprojects/FSharpx.Collections
Add LazyList.consLazy
Nobody has claimed this yet.
- Dominant language
- F#
- Stars
- 253
- Forks
- 76
- Avg merge
- 49m
- Merged PRs (30d)
- 1
Description
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the LazyList.consDelayed implementation and its existing tests. Add the requested LazyList.consLazy API and assess the proposed infix operator, then verify that the infinite ones example works and that the relevant tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fsharp
- Domain
- data
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100