Skip to content

uvtc/janet-rand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rand

Some functions to get you random things.

Examples

(import rand :prefix "")

(rand-int n)     #=> random integer from 0 to n - 1
(rand-int n m)   #=> random integer from n to m - 1
(rand-elem arr)  #=> random element from array

(rand-elems n arr)  #=> n random unique elements of the array
# Roll a `(length arr)`-sided die (one elem per side), n times:
(rand-rolls n arr)  #=> n random elems of arr (may repeat)

(shuffle arr)   #=> a copy of the array, shuffled

(rand-key tbl)  #=> random key   from a table
(rand-val tbl)  #=> random value from a table
(rand-kv  tbl)  #=> random key/value pair (tuple)

(rand-str n)    #=> random n-character lowercase string

About

Some functions to get you random things.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published