Standard Library¶
EasyLang includes a built-in Standard Library that provides essential utilities for:
- Mathematics
- Strings
- Lists
- Dictionaries
- Type conversion
- Random number generation
- File handling
- Python interoperability
- General utility functions
The standard library is composed of:
- Python functions wrapped automatically
- Built-in functions defined inside the interpreter
- EasyLang modules (
math.elangh,strings.elangh) - Built-ins added via
_wrap_python_module(math, random, etc.)
This chapter documents every major built-in available to EasyLang programs.
Overview of Categories¶
Math Utilities¶
String Utilities¶
List Utilities¶
Dictionary Access¶
Type Conversion¶
Ranges & Iteration Helpers¶
Random Number Utilities¶
Python Interop¶
File Utilities¶
1. Math Functions¶
Math functions come from two sources:
- your EasyLang math.elangh
- Python’s built-in math module, wrapped into EasyLang
Common functions (EasyLang + Python)¶
| Function | Description |
|---|---|
sqrt(x) |
square root |
pow(x, y) |
exponentiation |
sin(x) |
sine |
cos(x) |
cosine |
tan(x) |
tangent |
floor(x) |
round down |
ceil(x) |
round up |
abs(x) |
absolute value |
random() |
float between 0 and 1 |
randint(a, b) |
integer between a and b |
Example¶
bring math as m
so print m.sqrt(25)
we let x = m.randint(1, 100)
2. String Functions¶
These are provided via your strings.elangh module + built-in wrappers.
Functions
| Function | Description |
|---|---|
upper(text) |
convert to uppercase |
lower(text) |
convert to lowercase |
strip(text) |
remove whitespace |
substring(text, start, end) |
extract substring |
contains(text, sub) |
test membership |
startswith(text, sub) |
tests prefix |
endswith(text, sub) |
tests suffix |
Usage:
bring strings as s
so print s.upper("hello")
so print s.contains("easy", "sy")
3. List Utilities¶
Lists support several built-in methods automatically mapped by the interpreter.
Methods
| Method | Description |
|---|---|
list.push(value) |
append value |
list.pop() |
pop last item |
list.len() |
Length of list |
list.join(separator) |
join with separator |
Examples
we let nums = [1, 2, 3]
nums.push(4)
so print nums.len()
4. Dictionary Utilities¶
Dictionaries in EasyLang use attribute access:
Read values
user.name
user.age
Nested dictionaries
settings.database.port
Creating dictionaries
we let config = {
"host": "localhost",
"port": 8000
}
5. Type Conversion¶
The interpreter provides Python-style conversions:
| Function | Meaning |
|---|---|
int(x) |
convert to integer |
float(x) |
convert to floating-point |
str(x) |
convert to string |
Examples:
so print int("10")
so print float("3.14")
6. Range & Iteration Helpers¶
range(start, end) generates lists of numbers.
Example:
we let xs = range(1, 5)
so print xs $ [1, 2, 3, 4]
This is implemented in the interpreter and returns a Python list wrapped in EasyLang.
7. Random Utilities¶
Provided through Python's random module + your math module:
| Function | Description |
|---|---|
random() |
returns 0–1 float |
randint(a, b) |
integer in range |
choice(list) |
chooses random item |
Example:
bring random as r
we let n = r.randint(1, 10)
so print n
8. Python Interoperability (VERY POWERFUL)¶
This is one of EasyLang’s strongest features. Any Python module can be imported and used like a native EasyLang module.
Example:
bring os as o
so print o.getcwd()
Install a package using ELPM:
elpm --install requests
Now use in EasyLang:
bring requests as req
we let r = req.get("https://httpbin.org/get")
so print r.text
Every Python function, method, and property is wrapped automatically.
9. File Utilities (Built-in Keywords)¶
These are technically statements, but they act like part of the standard library:
| Keyword | Meaning |
|---|---|
open file as f for read |
open file |
open file as f for write |
create/overwrite |
writeline f with text |
write a line |
readline f into var |
read a line |
close f |
close file |
Example:
open "out.txt" as f for write
writeline f with "EasyLang!"
close f
10. Built-in Operators (English + Symbol Forms)¶
Arithmetic
plus (+)
minus (-)
mul (*)
div (/)
Comparison
equals (==)
not equals (!=)
less (<)
greater (>)
>= <=
Logic
and
or
not
These are implemented directly in the parser.
11. Utility Functions (from Python built-ins)¶
The interpreter exposes:
len(x)→ list/string lengthtype(x)→ type nameprint(x)→ raw Python print (rarely needed)
Example:
so print len([1, 2, 3])
Summary¶
The EasyLang Standard Library includes:
- math operations (EasyLang + Python math)
- string utilities
- list methods
- dictionary access via dot notation
- type conversion functions
- range generation
- random utilities
- Python module interoperability
- built-in file I/O system
- a wide variety of helper functions
The Standard Library allows EasyLang to be expressive, readable, and powerful while keeping syntax simple and English-like.
Next Steps¶
Continue to Error System to learn how Error System work in detail