import stdlib math as m
// Calculate hypotenuse
a = 3
b = 4
c = m.Sqrt(m.Pow(a, 2) + m.Pow(b, 2))
print("Hypotenuse:", c) // 5.0
// Trigonometry
angle = 3.14159 / 4 // 45 degrees
print("sin(45°):", m.Sin(angle))
print("cos(45°):", m.Cos(angle))
Time Module
import stdlib time as t
Function
Description
Returns
clock()
High-resolution timer
Float (seconds since epoch)
sleep(ms)
Pause execution
nil
timestamp()
Unix timestamp
Integer (seconds)
millis()
Milliseconds
Integer
year()
Current year
Integer
month()
Current month (1-12)
Integer
day()
Current day (1-31)
Integer
Example
import stdlib time as t
// Measure execution time
start = t.clock()
// Do some work
sum = 0
for (i in Range(1, 100001)) {
sum = sum + i
}
elapsed = t.clock() - start
print("Sum:", sum)
print("Time:", elapsed, "seconds")
// Date/time
print("Current year:", t.year())
print("Current month:", t.month())
print("Current day:", t.day())
// Pause execution
print("Waiting...")
t.sleep(1000) // 1 second
print("Done!")
IO Module
import stdlib io as io
Function
Description
Print(...)
Print with newline
Write(...)
Print without newline
Input(prompt)
Read user input
ReadFile(path)
Read file contents
WriteFile(path, content)
Write to file
AppendFile(path, content)
Append to file
FileExists(path)
Check if file exists
Example
import stdlib io as io
// User input
name = io.Input("Enter your name: ")
io.Print("Hello,", name)
// File operations
content = "Hello, File!"
io.WriteFile("test.txt", content)
if (io.FileExists("test.txt")) {
data = io.ReadFile("test.txt")
io.Print("File contents:", data)
}
io.AppendFile("test.txt", "\nMore content")
Built-in Functions
These functions are available globally without import: