Updated smnp.math (markdown)
18
smnp.math.md
18
smnp.math.md
@@ -1,6 +1,6 @@
|
|||||||
# Functions
|
# Functions
|
||||||
## random
|
## random
|
||||||
```
|
```php
|
||||||
random(min: int, max: int) #1
|
random(min: int, max: int) #1
|
||||||
random(min: float, max: float) #2
|
random(min: float, max: float) #2
|
||||||
random() #3
|
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
|
* `float` if passed arguments are of `float` type
|
||||||
|
|
||||||
## min
|
## min
|
||||||
```
|
```php
|
||||||
min(numbers: list<int, float>)
|
min(numbers: list<int, float>)
|
||||||
```
|
```
|
||||||
Returns the smallest number of given list.
|
Returns the smallest number of given list.
|
||||||
|
|
||||||
## max
|
## max
|
||||||
```
|
```php
|
||||||
max(numbers: list<int, float>)
|
max(numbers: list<int, float>)
|
||||||
```
|
```
|
||||||
Returns the greatest number of given list.
|
Returns the greatest number of given list.
|
||||||
|
|
||||||
## sample
|
## sample
|
||||||
```
|
```php
|
||||||
sample(list: list)
|
sample(list: list)
|
||||||
```
|
```
|
||||||
Returns a random item of given list.
|
Returns a random item of given list.
|
||||||
|
|
||||||
## pick
|
## pick
|
||||||
```
|
```php
|
||||||
pick(items: list<map<string><>>)
|
pick(items: list<map<string><>>)
|
||||||
pick(...items: 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.
|
The sum of `chance` value of each item should be equal to 100.
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
```
|
```php
|
||||||
items = [
|
items = [
|
||||||
{ chance -> 70, value -> "70%" },
|
{ chance -> 70, value -> "70%" },
|
||||||
{ chance -> 25, value -> "25%" },
|
{ chance -> 25, value -> "25%" },
|
||||||
@@ -67,18 +67,18 @@ println("5% : ", collected.countBy("5%"));
|
|||||||
```
|
```
|
||||||
|
|
||||||
## mod
|
## mod
|
||||||
```
|
```php
|
||||||
mod(a: int, b: int)
|
mod(a: int, b: int)
|
||||||
```
|
```
|
||||||
Returns the remainder after division of `a` by `b`.
|
Returns the remainder after division of `a` by `b`.
|
||||||
|
|
||||||
## range
|
## range
|
||||||
```
|
```php
|
||||||
range(begin: int, end: int, step: int = 1)
|
range(begin: int, end: int, step: int = 1)
|
||||||
```
|
```
|
||||||
Returns a list contained of integers from `begin` (inclusive) to `end` (exclusive) with given `step`.
|
Returns a list contained of integers from `begin` (inclusive) to `end` (exclusive) with given `step`.
|
||||||
|
|
||||||
#### Example
|
#### Example
|
||||||
```
|
```php
|
||||||
println(range(4, 20, 2)); # [4, 6, 8, 10, 12, 14, 16, 18]
|
println(range(4, 20, 2)); # [4, 6, 8, 10, 12, 14, 16, 18]
|
||||||
```
|
```
|
||||||
Reference in New Issue
Block a user