Extends the functionality of arrays in Hydra, letting you operate between different arrays and generate new ones.
.add
, .sub
, .mult
, .div
, .mod
These will let you add either a constant or an array to another array. If the second array is smaller than the first one, it simply stops there. For example:
[0,1,2,3].add(1) == [1,2,3,4]
[0,1,2,3].add([1,2]) == [1,3,2,3]
.addWrap
, .subWrap
, .multWrap
, .divWrap
, .modWrap
These are just like the regular operators, but if the second array is smaller than the first one, it'll repeat itself until going through every single element in the first array.
[0,1,2,3].add([1,2]) == [1,3,2,3]
[0,1,2,3].addWrap([1,2]) == [1,3,3,5]
.shuffle()
Will return a shuffled version of any array.
.zfill(length, z = 0)
Will concat z
to the array repeatedly until the array reaches the desired length. Inspired by python's zfill, however, the one shown here adds the zeroes at the end of the array.
.rotate(n)
/ .rot(n)
Will rotate the array by n
steps. Works with negative values.
Array.random(length = 10, min = 0, max = 1)
Generates a new array of a given length and fills it with random values between the range min
to max
.
Array.range(start, end, step = 1)
Generates a new array of numbers starting from start
, then each element increases by step
until end
(non-inclusive).
Array.range(end = 10, step = 1)
Generates a new array of numbers starting from 0, then each element increses by step
until end
(non-inclusive).