T
Tea
GitHub
Back to Reference

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) -> Void

Add an item to the end of the array

length() -> Int

Get 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) -> U

Reduce to single value

String

Immutable string operations and utilities

length() -> Int

Get 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() -> String

Remove leading and trailing whitespace

uppercase() -> String

Convert to uppercase

lowercase() -> String

Convert to lowercase

Math

Mathematical functions and constants

abs(x: Number) -> Number

Absolute value

sqrt(x: Number) -> Number

Square root

Example:

import Math
print(Math.sqrt(16))
# 4.0
pow(base: Number, exp: Number) -> Number

Exponentiation

floor(x: Number) -> Int

Round down to nearest integer

ceil(x: Number) -> Int

Round up to nearest integer

IO

Input/output operations for console and streams

print(value: Any) -> Void

Print value to stdout

Example:

print("Hello, Tea!")
print(42)
print([1, 2, 3])
println(value: Any) -> Void

Print value with newline

input(prompt: String) -> String

Read line from stdin

error(message: String) -> Void

Print 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
← Back to ReferenceNext: Collections →