question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generate built-in `Range`

See original GitHub issue

Hi! 👋 Was thinking of adding a built-in generator of the System.Range struct, as this would expand the default generator functionality. Am currently using this:

let range = gen {
  let! min = Gen.choose (0, Int32.MaxValue)
  let! max = Gen.choose (min, Int32.MaxValue)
  return Range (min, max) }

To make sure that the minimum is always lower than the maximum. But, with some additional options, one could include Range.StartAt and Range.EndAt too.

Just a suggestion when using the awesome FsCheck library 😉 .

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kurtschelfthoutcommented, Nov 7, 2022

Maybe an idea to create an extra generator that generate the built-in System.Range from an Interval?

Yeah I think that makes sense. Or even extract the code and parametrize the contructor, could be slightly faster without creating an intermediate type.

For standard types like System.Range I think it certainly makes sense to have them built-in.

0reactions
stijnmoreelscommented, Nov 7, 2022

Great! Happy to pick this up, but the supported frameworks on the main project are still not in the range where the System.Range is supported (net452;netstandard2.0;netstandard1.6;netstandard1.0) so maybe this could be set up on-hold till we update FsCheck towards .NET 6.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is a Python Generator? (Implementing Your Own ...
Generators in Python (also called generator functions) are used to create a series of values one at a time. Let's learn how they...
Read more >
Python range()
The range() function returns a sequence of numbers between the give range. Example. # create a sequence of numbers from 0 to 3...
Read more >
Built-in Functions — Python 3.11.4 documentation
The bytearray class is a mutable sequence of integers in the range 0 <= x < 256. It has most of the usual...
Read more >
How to generate range of numbers from 0 to n in ES2015 ...
Stick to range as util function or define your own object (with a type if using TS) and call it ArrayV2 or something....
Read more >
The Python range() Function (Guide)
In simple terms, range() allows you to generate a series of numbers within a given range. Depending on how many arguments you pass...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found