CorLang

Logo

View the Project on GitHub C1200/CorLang

← Back

Table of Contents

Modules & Imports

Importing Modules

To import modules use the import function.

import("mymodule.cor")

# If a module is in a different folder use:
import("myfolder/mymodule.cor")

Reserved Module Names

* is used as a wildcard.

File Name Use
std.* Standard Library
lib.* Reserved for future

Standard Library

std.list

list_join(list, separator)

Joins list items (must be a list of strings), separated by the separator string.

list_join(["Eggs", "Bread", "Milk"], ", ") # Outputs: "Eggs, Bread, Milk"
list_map(list, function)

Returns a new list populated with the results of calling the supplied function on each element in the supplied list. The function should take in the element and the index.

func square(elem, idx)
    return elem ^ 2
end
list_map([1, 2, 3, 4], square) # Outputs: [1, 2, 9, 16]
list_indexof(list, value)

Finds the supplied value in the list. If the item is found, the index of the item is returned. Otherwise, -1 is returned.

list_indexof([1, 2, 3, 4], 3) # Outputs: 2
list_indexof([1, 2, 3, 4], 5) # Outputs: -1