Skip to content

Built in functions

Eduard edited this page May 24, 2022 · 5 revisions

These are all the built-in functions in Kode. These names cannot be assigned to variables, as they are reserved.

print(arg) -> string

Prints its argument to the console.

Type conversions

toString(arg) -> string

Converts an argument (int, float, bool, string) to a string.

toInt(arg) -> int

Converts an argument (string of int, float, int) to a int. If argument is a float, the resulting int will be rounded down: toInt(5.7) returns 5.

toFloat(arg) -> float

Converts an argument (string of float, int, float) to a float.

String modification

yell(string) -> string

Converts a string to uppercase. yell("I love Kode") returns "I LOVE KODE"

whisper(string) -> string

Converts a string to lowercase. whisper("I love Kode") returns "i love kode"

Type Of

typeOf(arg) -> string

Returns the variable's type.

Array operations

len(arg) -> int

Returns the length of the argument (array, string). len([1,2,3]) returns 3, len("hello") returns 5.

append(array, element) -> array

Returns a new array consisting of the original array with the element added at the end of it. Does not modify the original array

truncate(array, index) -> array

Returns a new array consisting of the original array from which the element at the index is removed. Does not modify the original array

Random

random() -> float

Returns a random float between 0 (included) and 1 (excluded)

Math functions

round(float | int) -> float | int

Returns the float rounded to the nearest integer number.

sqrt(float | int) -> float | int

Returns the square root of a number.

Clone this wiki locally