Updated smnp.math (markdown)

Bartłomiej Przemysław Pluta
2020-04-02 09:15:49 +02:00
parent 5aa90b9343
commit 49914c7d22

@@ -1,6 +1,6 @@
# Functions
## random
```
```php
random(min: int, max: int) #1
random(min: float, max: float) #2
random() #3
@@ -12,25 +12,25 @@ Returns a random number from a given range _exclusively_ (`#1`, `#2`). Returns t
* `float` if passed arguments are of `float` type
## min
```
```php
min(numbers: list<int, float>)
```
Returns the smallest number of given list.
## max
```
```php
max(numbers: list<int, float>)
```
Returns the greatest number of given list.
## sample
```
```php
sample(list: list)
```
Returns a random item of given list.
## pick
```
```php
pick(items: list<map<string><>>)
pick(...items: map<string><>)
```
@@ -47,7 +47,7 @@ Returns a random item of given list using a configuration maps. It is a more gen
The sum of `chance` value of each item should be equal to 100.
#### Example
```
```php
items = [
{ chance -> 70, value -> "70%" },
{ chance -> 25, value -> "25%" },
@@ -67,18 +67,18 @@ println("5% : ", collected.countBy("5%"));
```
## mod
```
```php
mod(a: int, b: int)
```
Returns the remainder after division of `a` by `b`.
## range
```
```php
range(begin: int, end: int, step: int = 1)
```
Returns a list contained of integers from `begin` (inclusive) to `end` (exclusive) with given `step`.
#### Example
```
```php
println(range(4, 20, 2)); # [4, 6, 8, 10, 12, 14, 16, 18]
```