Standard Library
There isn't much development on the standard library yet.
Num
needs: nothing
.
Text -- toString()
Convert a number into its Text equivalet. Example: 5.toString(); // "5"
Num -- modulo(Num)
Get the remainder from division. Example: 5.modulo(2); // 1
Num -- floor()
Round down to the nearest integer. Example: 5.9.floor(); // 5
Num -- round()
Round to the nearest integer. Example: 5.5.round(); // 6
Num -- ceil()
Round up to the nearest integer. Example: 5.1.ceil(); // 6
Num -- squared()
Take the number to the second power. Example: 4.squared(); // 16
Num -- abs()
Get the absolute value of the number. Example: -4.abs(); // 4
Num -- orMaxOf(Num)
Return the argument Num if greater than the target number, otherwise return the target number. Example: 5.orMaxOf(8); // 8
Num -- orMaxOf(Num[])
Return the largest number in the list, or the number itself if it is larger than each element in the list. Example: 5.orMaxOf([2, 5, 8]); // 8
Num -- orMinOf(Num)
Return the argument Num if less than the target number, otherwise return the target number. Example: 5.orMinf(8); // 5
Num -- orMinOf(Num[])
Return the smallest number in the list, or the number itself if it is smaller than each element in the list. Example: 5.orMinOf([2, 5, 8]); // 2
Num -- numberOfDigits()
Count how many digits are in the number. Example: 123.numberOfDigits(); // 3
Num -- range(Num)
Return a list of each number including and up to the argument, beginning at the target number. Example: 5.range(8); // [5, 6, 7, 8]
Text
needs: nothing
.
Text -- join(Text[])
Join together the list of texts by a glue string. Example: ", ".join(["hey", "not cool"]); // "hey, not cool"
Text -- toUpper()
Get the all uppercase equivalent of the target text. Example: "Hello".toUpper(); // "HELLO"
Text -- toLower()
Get the all lowercase equivalent of the target text. Example: "Hello".toLower(); // "hello"
Text -- switchCase()
Swap the casing of each charecter in the target text. Example: "Hello".switchCase(); // "hELLO"
Text -- trim()
Remove whitespace (tabs, newlines, spaces, etc) from the beginning and ending of the Text. Example: " Hello ".trim(); // "Hello"
Num -- getSize()
Get the number of characters in a Text. Example: "Hello".getSize(); // 5
Text -- substr(Num start)
Cut from the character at the starting index until the end of the Text. A negative start index counts from the end of the Text. Example: "Hello".substr(1); // "ello"
Text -- substr(Num start, Num end)
Cut from the character at the starting index until the ending index of the Text. A negative start or ending index counts from the end of the Text. Example: "Hello".substr(1, 3); // "ell"
Num? -- parseNum()
Read the Text as if it were a Num. If parsing fails, it will return nothing. Example: "5.5".parseNum(); // 5.5
Text? -- charAt(Num)
Get the character at a particular index of the Text, or nothing if the index is longer than the Text. Example: "Hello".charAt(2); // "e"
Text[] -- split(Text)
Find each occurence of Text within the target Text, and return the content that separates them in a List. Example: "Foo bar baz".split(" "); // ["Foo", "bar", "baz"]
Num? -- indexOf(Text)
Return the index of the first occurence of Text. If it never occurs, return nothing. Example: "Hello".indexOf("l"); // 2
Bool
needs: nothing
.
Text -- toString()
Convert a Bool into its Text equivalet. Example: true.toString(); // "true"
List{T}
needs: nothing
.
List{T} is the autoboxed form of with T[]. Due to special semantics the other autoboxed classes don't have, you should for the moment avoid using List{T} and stick with T[] instead.
Num -- getSize()
Count the elements in the list. Example: [1, 2].getSize(); // 2
Bool -- contains(T)
Check if a particular element exists within a List. Example: [1, 2].contains(2); // true
T[] -- intersect(T[])
Keep all elements that exist in both the target List and T[]. Example: [1, 2, 3].intersect([2, 3, 4]); // [2, 3]
push(T)
Add an item to the end of a List. Example: Num[].push(2);
Map{K,V}
needs: nothing
.
Map variables of type K to variables of type V. Bad performance at the moment.
put(K, V)
Add value V at key K. Example: Map.put(Person.getName(), Person);
V? -- get(K)
Extract a value by index from the map, or get Nothing if there is no value for that key. Example: var Person? = Map.get('Johnny');
K[] -- getKeys()
Get all the defined keys in a map. Example: var Text[] names = Map.getKeys();
Printer
needs: nothing
.
print(Text)
Print the text and no newline afterwards. Example: Printer.print("hello");
printLine(Text)
Print the text and a newline afterwards. Example: Printer.printLine("hello");
print(Num)
Print the number and no newline afterwards. Example: Printer.print(5);
printLine(Num)
Print the number and a newline afterwards. Example: Printer.printLine(5);
FileSystem
FilePath -- getPath(Text)
Get the object representation of a path in the filesystem. Example: var FilePath = FileSystem.getPath("/usr/local/bin")
FilePath[] -- listRoots()
Return all root points in the filesystem. Unix variants will return /, while windows variants will return C:/, D:/, etc.
Text -- getPathSeparator()
Get the character required to separate entries in the PATH variable for the current operating system.
FilePath -- getTempFile(Text prefix, Text suffix, FilePath)
Using the prefix and suffix, open a file with a unique name within the directory FilePath. Actually, this needs to return File so that its atomic....
FilePath
provides File
Open a readable/writable file at this path. Example: var File from FilePath;
Text -- getPath()
Get the full text path of the file. Example: Printer.printLine(FilePath.getPath())
Text -- getBasename()
Return the name of the file without the directory preceding it. Example: FileSystem.path("../File.txt").getBasename(); // "File.txt"
Text -- getDirname()
Return the name of the directory containing the directory or file that may exist at this path. Example: FileSystem.path("docs/File.txt").getPath(); // "docs"
Text -- isFile()
Check if a file exists at the location, which is not a directory. Example: FileSystem.path("docs/File.txt").isFile(); // true
Text -- isDirectory()
Check if a directory exists at the location. Example: FileSystem.path("docs/File.txt").isDirectory(); // false
Text -- fileExists()
Check if a file or directory exists at the location. Example: FileSystem.path("docs/File.txt").fileExists(); // true
makeDirectory()
Create a new directory at the location. Example: FileSystem.path("docs/").makeDirectory();
FilePath[] -- getChildren()
List the contents of the directory at the location. Example: var FilePath[] = FileSystem.path("docs").getChildren();
FilePath? -- getParent()
Get the containing folder of the file or folder that exists at this location. Returns nothing if there is no parent. Example: var FilePath? = FileSystem.path("docs").getParent();
delete()
Delete any folder or file that exists at this location. Example: FileSystem.path("docs/File.txt").delete();
File
needs: FilePath
.
FilePath -- getPath()
Get the object representation of the path to this file. Example: File.getPath().getBasename();
Text -- read(Num)
Read Num characters from the file at the current point of the cursor.
Text -- readUnsignedChar()
Read a byte of the file as a binary, from value 0-255.
write(Text)
Write a string into a file at the current point of the cursor.
close()
Close the file. At the moment subsequent writes or reads will crash your program. Later it will throw an exception.
Num -- tell()
Get the current position of the read/write cursor position in the file.
seek(Num)
Set the current position of the read/write cursor position in the file.
Bool -- eof()
Check if the cursor position is at the end of the file.
Argv
needs: nothing
.
Text[] -- getArgv()
Get the arguments supplied to running the executable. Will likely be renamed or maybe encapsulated elsewhere. Example: needs Argv, Printer then { Printer.print(Argv.getArgv()[0]); }
System
needs: nothing
.
exit(Num)
Exit program with a return code. By convention, a non-zero exit value is considered an error. Example: System.exit(0);