Because this function works by adding 1 to the random number generated between 1 and a maximum value, the lowest possible return for this function is 2.
In addition, the above version will loudly fail if a list has only one item.
So: in it's current form, the function returns a random list item between the 2nd and last, but only if the list has at least two items.
The subtraction and addition seem to be unnecessary; a straight random(length($list))) works just fine, and hits all potential numbers in the list.
The version included in this PR makes it so that the function simply returns a random list item:
As mentioned (albeit briefly) in #50, the random function is currently broken :sob:
Previously,
@function sl-random-value
looked like this:Because this function works by adding 1 to the random number generated between 1 and a maximum value, the lowest possible return for this function is 2.
In addition, the above version will loudly fail if a list has only one item.
So: in it's current form, the function returns a random list item between the 2nd and last, but only if the list has at least two items.
The subtraction and addition seem to be unnecessary; a straight random(length($list))) works just fine, and hits all potential numbers in the list.
The version included in this PR makes it so that the function simply returns a random list item: