Library std

v1.0.0Adam Yarris GitHub Examples

The standard library for the Qilletni language

Entities

int An integer value, up to 64 bits.
double A double precision floating point value, up to 64 bits.
string A character string.
boolean A true/false value.
collection A playlist or collection of songs
song A provider-agnostic piece of music that can be interacted with through service providers.
album A provider-agnostic musical album that can be interacted with through service providers.
list A dynamic collection of types.
java A reference to a Java object, for interacting with native methods.
function A Qilletni native type.
Artist An artist who creates songs.
Date An entity that may store a date (not time).
Map A HashMap wrapper that may store keys and values of any type.
Optional An entity that may either hold a value or be empty. The value being held may be anything.
Queue
Stack
User An end user/listener of a song provider that may own playlists.

Global Functions

native fun _emptyJavaMap() Creates an empty HashMap instance.
native fun backtrace() Prints out the current stacktrace of the program.
native fun breakpoint() Pauses the program and puts the user in a debugger.
native fun breakpoint(condition) Pauses the program and puts the user in a debugger if the given condition is true.
native fun bt() Prints out the current stacktrace of the program.
native fun currentTimeMillis() Gets the current time in milliseconds
native fun defaultPlay(songToPlay) Play a song via the default "play" keyword invoked as a function, which will call the default "play" action as if no redirection happened.
native fun exit(code) Exits the program with the given exit code.
native fun functions() Prints out the functions in the current scope and all parents.
native fun functions(entityInstance) Prints out the functions in the given entity's scope and all parents.
native fun getEnv(name) Gets the environment variable of a given name. This will return a string, or throw an error if it can't be found.
fun getEnv(name, default) Gets the environment variable of a given name. If the value is not found, a default value is returned.
native fun hasEnv(name) Checks if an environment variable is set.
native fun print(obj) Prints a string representation of the given object to the console, followed by a newline character.
fun printf(obj, formatParams) Prints a given string to the console, followed by a newline character. The string is formatted with string.format using the parameters provided.
native fun processBackground() Process background tasks until the program is terminated.
native fun random(min, max) Generates a random integer between an inclusive lower bound and an exclusive upper bound.
native fun readLine() Reads a line of input from the console.
native fun redirectPlayToFunction(fn) Starts making all plays invoke the given function with 1 parameter of the song.
native fun redirectPlayToList(songList) Starts making all plays add to a song list instead of the previous play action.
native fun redirectReset() Stops all 'play's from any set action and returns it back to its default action.
native fun vars() Prints out the variables and their values in the current scope and all parents.
native fun vars(entityInstance) Prints out the variables and their values in the given entity's scope and all parents.

Extension Functions

native fun getAllArtists() on album Gets all Artist s of the album.
native fun getArtist() on album Gets the primary Artist of the album.
native fun getId() on album Gets the ID of an album.
native fun getName() on album Gets the name of an album.
native fun getUrl() on album Gets the URL of an album.
native fun anySongMatches(fn) on collection Loops through all songs of the collection and checks if the condition is matched.
native fun containsArtist(artist) on collection Checks if the collection contains any song with the given artist as the song's first artist.
native fun getCreator() on collection Gets the creator of the collection.
native fun getId() on collection Gets the ID of the collection. This is an ID identifiable by the provider which owns this collection.
native fun getName() on collection Gets the name of the collection.
native fun getTrackCount() on collection Gets the number of tracks in the collection.
native fun getUrl() on collection Gets the URL of the collection.
native fun add(item) on list Adds an item to the list.
native fun add(index, item) on list Adds an item to the list at the specified index.
native fun addAll(itemList) on list Adds all items of the given list to the current list.
native fun contains(item) on list Checks if the given item is contained in the list.
native fun indexOf(item) on list Checks the index of the given item in the list.
fun isEmpty(lst) on list Checks if the list is empty.
native fun join(delimiter) on list Joins the items of the list into a single string.
native fun remove(index) on list Removes an item from the list at the given index.
native fun size() on list Gets the size of the list.
native fun sort() on list Sorts a list of numbers or strings in-place.
native fun sortReverse() on list Sorts a list of numbers or strings in-place, in reverse order.
native fun subList(fromIndex, toIndex) on list Returns a portion of the current list from the specified starting index to the end of the list.
native fun getAlbum() on song Gets the Album the song is on.
native fun getAllArtists() on song Gets all Artist entities on the song.
native fun getArtist() on song Gets the Artist entity of the primary artist on the song
native fun getDuration() on song Gets the duration of the song in milliseconds.
native fun getId() on song Gets the ID of the song. This is an ID identifiable by the provider which owns this song.
native fun getTitle() on song Gets the name of the song.
native fun getUrl() on song Gets the URL of the song. If it was not defined with a URL, an empty string is returned.
native fun contains(comparing) on string Checks if the string contains the given string.
native fun format(formatList) on string Performs typical C-style string formatting. Only strings, doubles, and integers are supported.
native fun length() on string Gets the length of a string.
native fun substring(beginIndex) on string Returns a substring of the current string from the given index.
native fun substring(beginIndex, endIndex) on string Returns a substring of the current string from and to specified indices
native fun toInt() on string Converts the string to an integer.
native fun toLower() on string Returns the string in all lowercase.
native fun toUpper() on string Returns the string in all uppercase.
native fun _emptyJavaMap() link

Creates an empty HashMap instance.

Returns HashMap

An instance of a HashMap

native fun backtrace() link

Prints out the current stacktrace of the program.

native fun breakpoint() link

Pauses the program and puts the user in a debugger.

Returns int

The number of milliseconds spent in the debugger

native fun breakpoint(condition) link

Pauses the program and puts the user in a debugger if the given condition is true.

Returns int

The number of milliseconds spent in the debugger, or -1 if the condition is false

native fun bt() link

Prints out the current stacktrace of the program.

native fun currentTimeMillis() link

Gets the current time in milliseconds

Returns int

The current time in milliseconds

native fun defaultPlay(songToPlay) link

Play a song via the default "play" keyword invoked as a function, which will call the default "play" action as if no redirection happened.

Params
songToPlay ( song )

The song

native fun exit(code) link

Exits the program with the given exit code.

Params
code ( int )

The exit code to exit with

native fun functions() link

Prints out the functions in the current scope and all parents.

native fun functions(entityInstance) link

Prints out the functions in the given entity's scope and all parents.

Params
entityInstance

The instance of the entity to get the scope of

native fun getEnv(name) link

Gets the environment variable of a given name. This will return a string, or throw an error if it can't be found.

Params
name ( string )

The name of the environment variable to get

Returns

The value of the environment variable

fun getEnv(name, default) link

Gets the environment variable of a given name. If the value is not found, a default value is returned.

Params
name ( string )

The name of the environment variable to get

defaultValue ( string )

The default value to return if the environment variable is not found

Returns

The value of the environment variable

native fun hasEnv(name) link

Checks if an environment variable is set.

Params
name ( string )

The name of the environment variable to check for

Returns boolean

true if the environment variable is set, false if otherwise

native fun print(obj) link

Prints a string representation of the given object to the console, followed by a newline character.

Params
obj

The object to print, of any type.

fun printf(obj, formatParams) link

Prints a given string to the console, followed by a newline character. The string is formatted with string.format using the parameters provided.

Params
obj

The object to print, of any type.

native fun processBackground() link

Process background tasks until the program is terminated.

native fun random(min, max) link

Generates a random integer between an inclusive lower bound and an exclusive upper bound.

Params
min ( int )

The inclusive minimum range of the random number

max ( int )

The exclusive maximum range of the random number

Returns int

A random integer between the given range

native fun readLine() link

Reads a line of input from the console.

Returns

The line of input read from the console

native fun redirectPlayToFunction(fn) link

Starts making all plays invoke the given function with 1 parameter of the song.

Params
fn

The function to call with the song as an argument

native fun redirectPlayToList(songList) link

Starts making all plays add to a song list instead of the previous play action.

Params
songList ( list )

The list to add songs to

native fun redirectReset() link

Stops all 'play's from any set action and returns it back to its default action.

native fun vars() link

Prints out the variables and their values in the current scope and all parents.

native fun vars(entityInstance) link

Prints out the variables and their values in the given entity's scope and all parents.

Params
entityInstance

The instance of the entity to get the scope of