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

set_random(2025) returns false. #2754

Closed
dcnorris opened this issue Jan 7, 2025 · 6 comments
Closed

set_random(2025) returns false. #2754

dcnorris opened this issue Jan 7, 2025 · 6 comments

Comments

@dcnorris
Copy link

dcnorris commented Jan 7, 2025

?- use_module(library(random)).
   true.
?- Seed = 2025, set_random(Seed).
   false. % expected `true`
@bakaq
Copy link
Contributor

bakaq commented Jan 7, 2025

?????????????????????????????

@triska
Copy link
Contributor

triska commented Jan 7, 2025

Expected is a domain error.

?- set_random(seed(2025)).
   true. % expected

Any solutions where the argument is an integer?

?- length(_, L), set_random(L).
   loops, unexpected.

@dcnorris
Copy link
Author

dcnorris commented Jan 7, 2025

Thanks for this clarification, @triska! Random seeds are (in my experience) usually understood to be integers, so I wasn't expecting to need the seed/1 wrapper here. (If the function had reported a domain error, however, that would have given me the needed hint.)


This raises the question, however, what useful function seed/1 serves here.

@triska
Copy link
Contributor

triska commented Jan 7, 2025

The wrapper seed/1 is used to distinguish the argument from other possible arguments which may be supported in the future. Notable examples for this are:

  • an attained state of the generator that was previously obtained with a different predicate
  • a seed that needs more than one argument
  • a way to select a specific kind of generator (?)
  • ...

For comparison, please see the SICStus version and possibly other proposals too:

https://sicstus.sics.se/sicstus/docs/latest/html/sicstus.html/lib_002drandom.html

@dcnorris
Copy link
Author

dcnorris commented Jan 7, 2025

I see there's an entire Rust Rand Book, and wonder if the best approach for Scryer might be to leverage this by providing a straightforward interface to those facilities. This could at least serve to flesh out an interface to multiple generators, etc. Presumably, the intense interest in Rust from the scientific community would ensure that this crate is heavily used, tested, etc. Also, someone from that community coming to Scryer would immediately be familiar with the menagerie of RNG options, and able to port work into Scryer as desired.

In any case, I think this is now a non-Issue, and should be closed.

@dcnorris dcnorris closed this as completed Jan 7, 2025
@adri326
Copy link
Contributor

adri326 commented Jan 7, 2025

Note that there have been talks in #2670 about doing exactly that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants