From 3d317ff28e0a719295ec4633c82776ad8f8235f8 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Mon, 27 Feb 2023 21:38:02 +1100 Subject: [PATCH] Updated standard library --- getting-started/standard-library.md | 61 +++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 16 deletions(-) diff --git a/getting-started/standard-library.md b/getting-started/standard-library.md index 68d3ef2..b5d358c 100644 --- a/getting-started/standard-library.md +++ b/getting-started/standard-library.md @@ -8,14 +8,56 @@ The standard library can usually be accessed with the `import` keyword: import standard; ``` -## abs(self) - -This function returns the absolute value of any integer or float passed in. +# Misc. Utilities +
## clock() 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 +
+ +## 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 +
+ ## 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`. @@ -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. -## 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) This function returns the first index within `self` that is equal to `value`, or `null` if none are found.