Built in Functions - Pranav-Lejith/Orion GitHub Wiki

Built-in Functions Reference

Math Functions

abs(-5)          # Absolute value → 5
round(3.7)       # Round → 4
sqrt(16)         # Square root → 4.0
sin(1.57)        # Sine → ~1.0
cos(0)           # Cosine → 1.0
tan(0.785)       # Tangent → ~1.0
log(10)          # Natural logarithm
exp(1)           # e^x → ~2.718
floor(3.7)       # Round down → 3
ceil(3.2)        # Round up → 4
min([1,2,3])     # Minimum → 1
max([1,2,3])     # Maximum → 3
sum([1,2,3])     # Sum → 6

Type Conversion

int("42")        # Convert to integer → 42
float("3.14")    # Convert to float → 3.14
str(42)          # Convert to string → "42"
bool(1)          # Convert to boolean → True
type(42)         # Get type → "int"

String Functions

upper("hello")           # Uppercase → "HELLO"
lower("HELLO")           # Lowercase → "hello"
capitalize("hello")      # Capitalize → "Hello"
strip("  hello  ")       # Remove whitespace → "hello"
split("a,b,c", ",")      # Split string → ["a", "b", "c"]
join(",", ["a","b"])     # Join strings → "a,b"
replace("hello", "l", "x") # Replace → "hexxo"
find("hello", "ll")      # Find substring → 2
len("hello")             # Length → 5

List Functions

len([1,2,3])             # Length → 3
append(my_list, item)    # Add item to end
extend(list1, list2)     # Add all items from list2
insert(my_list, 0, item) # Insert at position
remove(my_list, item)    # Remove first occurrence
pop(my_list)             # Remove and return last item
clear(my_list)           # Remove all items
index(my_list, item)     # Find index of item
reverse(my_list)         # Reverse in place
sorted(my_list)          # Return sorted copy

Dictionary Functions

keys(my_dict)            # Get all keys
values(my_dict)          # Get all values
items(my_dict)           # Get key-value pairs
get(my_dict, "key")      # Get value safely
update(dict1, dict2)     # Merge dictionaries

Random Functions

randint(1, 10)           # Random integer 1-10
choice(["a","b","c"])    # Random choice from list
shuffle(my_list)         # Shuffle list in place

Utility Functions

range(5)                 # Generate numbers 0-4
range(1, 6)              # Generate numbers 1-5
enumerate(my_list)       # Add indices to list
zip(list1, list2)        # Combine lists

Custom Orion Functions

add(5, 3)                # Simple addition → 8
calculator(10, 5, "add") # Calculator function → 15
hypotenuse(3, 4)         # Pythagorean theorem → 5.0
pickRandom(my_list)      # Pick random item
coloredText("Hi", "red") # Create colored text

Date/Time Functions

now()                    # Current date/time
date(2023, 12, 25)       # Create date
time(14, 30, 0)          # Create time

JSON Functions

json_dumps(data)         # Convert to JSON string
json_loads(json_string)  # Parse JSON string