mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Updated standard library
This commit is contained in:
@@ -8,14 +8,56 @@ The standard library can usually be accessed with the `import` keyword:
|
|||||||
import standard;
|
import standard;
|
||||||
```
|
```
|
||||||
|
|
||||||
## abs(self)
|
# Misc. Utilities
|
||||||
|
<hr />
|
||||||
This function returns the absolute value of any integer or float passed in.
|
|
||||||
|
|
||||||
## clock()
|
## clock()
|
||||||
|
|
||||||
This function returns a string representation of the current timestamp.
|
This function returns a string representation of the current timestamp.
|
||||||
|
|
||||||
|
## hash(self)
|
||||||
|
|
||||||
|
This function returns a hashed value of `self`.
|
||||||
|
|
||||||
|
This function uses the internal literal hashing algorithms. As such, the following can't be hashed:
|
||||||
|
|
||||||
|
* functions
|
||||||
|
* types
|
||||||
|
* opaques
|
||||||
|
* `null`
|
||||||
|
|
||||||
|
Any attempt to hash these will return -1, except `null` which returns 0.
|
||||||
|
|
||||||
|
# Maths Utilities
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
## abs(self)
|
||||||
|
|
||||||
|
This function returns the absolute value of any integer or float passed in.
|
||||||
|
|
||||||
|
## ceil(self): int
|
||||||
|
|
||||||
|
This function returns the value of any integer or float passed in, rounded up.
|
||||||
|
|
||||||
|
## floor(self): int
|
||||||
|
|
||||||
|
This function returns the value of any integer or float passed in, rounded down.
|
||||||
|
|
||||||
|
## max(...)
|
||||||
|
|
||||||
|
This function returns the value of the highest integer or float passed in. It can take any number of arguments.
|
||||||
|
|
||||||
|
## min(...)
|
||||||
|
|
||||||
|
This function returns the value of the lowest integer or float passed in. It can take any number of arguments.
|
||||||
|
|
||||||
|
## round(self): int
|
||||||
|
|
||||||
|
This function returns the value of any integer or float passed in, rounded to the nearest whole number.
|
||||||
|
|
||||||
|
# Compound Utilities
|
||||||
|
<hr />
|
||||||
|
|
||||||
## concat(self, other)
|
## concat(self, other)
|
||||||
|
|
||||||
This function only works when self and other are matching compounds (both arrays, dictionaries or strings). It returns a new compound of that kind, with the content of `other` appended to the content of `self`.
|
This function only works when self and other are matching compounds (both arrays, dictionaries or strings). It returns a new compound of that kind, with the content of `other` appended to the content of `self`.
|
||||||
@@ -60,19 +102,6 @@ This function returns an array of all non-null keys stored within the dictionary
|
|||||||
|
|
||||||
This function returns an array of all values with non-null keys stored within the dictionary. The order is undefined.
|
This function returns an array of all values with non-null keys stored within the dictionary. The order is undefined.
|
||||||
|
|
||||||
## hash(self)
|
|
||||||
|
|
||||||
This function returns a hashed value of `self`.
|
|
||||||
|
|
||||||
This function uses the internal literal hashing algorithms. As such, the following can't be hashed:
|
|
||||||
|
|
||||||
* functions
|
|
||||||
* types
|
|
||||||
* opaques
|
|
||||||
* `null`
|
|
||||||
|
|
||||||
Any attempt to hash these will return -1, except `null` which returns 0.
|
|
||||||
|
|
||||||
## indexOf(self: array, value)
|
## indexOf(self: array, value)
|
||||||
|
|
||||||
This function returns the first index within `self` that is equal to `value`, or `null` if none are found.
|
This function returns the first index within `self` that is equal to `value`, or `null` if none are found.
|
||||||
|
|||||||
Reference in New Issue
Block a user