Standard Library
Core modules and functions that are available in every Tea program without explicit imports.
Array
Dynamic arrays with type-safe operations
append(item: T) -> VoidAdd an item to the end of the array
length() -> IntGet the number of items in the array
map<U>(fn: (T) -> U) -> Array<U>Transform each element
Example:
var numbers = [1, 2, 3]
var doubled = numbers.map(n => n * 2)
# [2, 4, 6]filter(fn: (T) -> Bool) -> Array<T>Filter elements by predicate
reduce<U>(initial: U, fn: (U, T) -> U) -> UReduce to single value
String
Immutable string operations and utilities
length() -> IntGet the length of the string
split(delimiter: String) -> Array<String>Split string by delimiter
Example:
var text = "hello,world,tea"
var parts = text.split(",")
# ["hello", "world", "tea"]trim() -> StringRemove leading and trailing whitespace
uppercase() -> StringConvert to uppercase
lowercase() -> StringConvert to lowercase
Math
Mathematical functions and constants
abs(x: Number) -> NumberAbsolute value
sqrt(x: Number) -> NumberSquare root
Example:
import Math
print(Math.sqrt(16))
# 4.0pow(base: Number, exp: Number) -> NumberExponentiation
floor(x: Number) -> IntRound down to nearest integer
ceil(x: Number) -> IntRound up to nearest integer
IO
Input/output operations for console and streams
print(value: Any) -> VoidPrint value to stdout
Example:
print("Hello, Tea!")
print(42)
print([1, 2, 3])println(value: Any) -> VoidPrint value with newline
input(prompt: String) -> StringRead line from stdin
error(message: String) -> VoidPrint to stderr
Using the Standard Library
Most standard library functions are available globally without imports. For module-specific functions, use the import statement:
import Math
import JSON
import File