Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seed the generator #84

Closed
aloisdg opened this issue Oct 20, 2021 · 0 comments · Fixed by #85
Closed

Seed the generator #84

aloisdg opened this issue Oct 20, 2021 · 0 comments · Fixed by #85
Assignees
Labels
enhancement New feature or request hacktoberfest hacktoberfest-accepted A pull request is considered approved once it has an overall approving review from maintainers, or h
Milestone

Comments

@aloisdg
Copy link
Member

aloisdg commented Oct 20, 2021

Hi!

I think for testing purpose, being able to seed the randomization could be useful. This would help fix issue raised on #83

The Random logic is in next and was based on a snippet by @tpetricek

    static member private next =
        let seedGenerator = Random()

        let localGenerator =
            new ThreadLocal<Random>(fun _ ->
                lock
                    seedGenerator
                    (fun _ ->
                        let seed = seedGenerator.Next()
                        Random(seed)))

        fun n -> localGenerator.Value.Next(n)

Random() can be seeded by passing a parameter Random(seed).

Cheers,

@aloisdg aloisdg added enhancement New feature or request hacktoberfest hacktoberfest-accepted A pull request is considered approved once it has an overall approving review from maintainers, or h labels Oct 20, 2021
@aloisdg aloisdg added this to the vNext milestone Oct 20, 2021
aloisdg pushed a commit that referenced this issue Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest hacktoberfest-accepted A pull request is considered approved once it has an overall approving review from maintainers, or h
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants