Module
random
Module random
Definitions
bidalaka/random
1.1.0
Functions
arrayMember
function arrayMember(any[] arr) returns any
Parameters
- arr any[] -
arrayMembers
function arrayMembers(any[] arr, int count) returns any[]
Selects a random set of members from the given array.
Return Type
- any[] - An array of either
count
orarr.length()
members, whichever is smaller, or () if the array is empty
mapKey
Selects a random key from the map.
Parameters
- m map<any> - The map to select from
Return Type
- string? - A random key, or () if the map is empty
shuffle
function shuffle(any[] arr) returns any[]
Shuffles the array.
Parameters
- arr any[] - The array to shuffle
Return Type
- any[] - An array containing all the members of
arr
, shuffled
tableRow
function tableRow(table<record{}> key<anydata> tb) returns any
Selects a random row from a table. Note: this currently calls keys()
and so will be
expensive for large tables.
Parameters
- tb table<record{}> key<anydata> - The table to select from.
Return Type
- any - A randomly selected row from the table, or () if the table is empty.
Import
import bidalaka/random;
Metadata
Released date: about 3 years ago
Version: 1.1.0
License: Apache 2.0
Compatibility
Platform: any
Ballerina version: slbeta2
GraalVM compatible: Yes
Pull count
Total: 4
Current verison: 4
Weekly downloads
Contributors
Other versions
1.1.0
Dependencies