ciao-lang / ciao

Ciao is a modern Prolog implementation that builds up from a logic-based simple kernel designed to be portable, extensible, and modular.
https://ciao-lang.org
GNU Lesser General Public License v3.0
272 stars 21 forks source link

Feature request random/3 that works with bigint #76

Open Jean-Luc-Picard-2021 opened 2 years ago

Jean-Luc-Picard-2021 commented 2 years ago

I guess random/3 always generates zero, for a large M:

/* Ciao 1.22.0 */
?- M is (1<<101), random(0,M,X).
X = 0

?- M is (1<<101), random(0,M,X).
X = 0

Doesn’t happen for a smallint argument:

?- random(0,77,X).
X = 62

?- random(0,77,X).
X = 71

What about a random/3 that could deal with bigints, like random_between/3 from SWI-Prolog?