random works on tuples

This commit is contained in:
Scott Richmond 2024-11-01 16:23:15 -04:00
parent a7fcad18a6
commit ee09b9f208

View File

@ -984,7 +984,7 @@ fn heading/vector {
&&& more number functions &&& more number functions
fn random { fn random {
"Returns a random something. With zero arguments, returns a random number between 0 (inclusive) and 1 (exclusive). With one argument, returns a random number between 0 and n. With two arguments, returns a random number between m and n. Alternately, given a collection (list, dict, set), it returns a random member of that collection." "Returns a random something. With zero arguments, returns a random number between 0 (inclusive) and 1 (exclusive). With one argument, returns a random number between 0 and n. With two arguments, returns a random number between m and n. Alternately, given a collection (tuple, list, dict, set), it returns a random member of that collection."
() -> base :random () () -> base :random ()
(n as :number) -> mult (n, random ()) (n as :number) -> mult (n, random ())
(m as :number, n as :number) -> add (m, random (sub (n, m))) (m as :number, n as :number) -> add (m, random (sub (n, m)))