ExprUA Editor

Core Features

Unit-Aware Expressions

Built-in support for physical units with automatic dimensional analysis and conversion

Dimensional Consistency

Compile-time and runtime checking ensures you never mix incompatible units

Pythonic Syntax

Familiar syntax with functions, loops, conditionals, and indentation-based blocks

Rich Unit Library

SI units, imperial units, and comprehensive physical constants built-in

Module System

Organize code with imports and exports for reusable calculations

Mutable Collections

Arrays and dictionaries with full mutation support for complex data

Quick Example

Calculate the kinetic energy of an object with dimensional safety:

# Define variables with units
mass = 5 kg
velocity = 10 m/s

# Compute kinetic energy
kinetic_energy = 0.5 * mass * velocity^2

# Result: 250 kg⋅m²/s² (or 250 J)

Variables & Units

Variables can hold values with physical units. Units are automatically converted to base SI units internally:

# Basic variables with units
distance = 100 m
time = 9.58 s
speed = distance / time  # → 10.44 m/s

# Imperial units auto-convert
height = 6 ft  # → 1.83 m
weight = 150 lb  # → 68.04 kg

# Arrays with units
velocities = [10, 20, 30] m/s
forces = [100, 200, 150] N

Operators

Standard mathematical operators with unit-aware semantics:

# Arithmetic with dimensional analysis
force = 50 N
area = 2 m^2
pressure = force / area  # → 25 Pa

# Exponentiation
radius = 5 m
volume = 4/3 * pi * radius^3  # → m³

# Comparisons
is_fast = speed > 10 m/s  # → true

Control Flow

Conditionals

if temperature > 373.15 K:
    phase = "gas"
elif temperature > 273.15 K:
    phase = "liquid"
else:
    phase = "solid"

# Ternary operator
result = velocity > 0 ? "moving" : "stationary"

Loops

# For loop with range
for i in range(10):
    print(i)

# While loop
while distance < 100 m:
    distance = distance + velocity * time_step

# Repeat-until loop
repeat:
    force = force - 1 N
until force < 10 N

Functions

Define reusable calculations with optional unit annotations:

# Function with unit annotations
def kinetic_energy(m: kg, v: m/s) -> J:
    return 0.5 * m * v^2

# Function without annotations (flexible)
def calculate_force(mass, acceleration):
    return mass * acceleration

# Call with keyword arguments
energy = kinetic_energy(m=5 kg, v=10 m/s)

Built-in Functions

ExprUA includes a rich set of mathematical and statistical functions:

Unit System

Base SI Units

All quantities are based on the International System of Units:

Common Derived Units

N   # Newton (force)
J   # Joule (energy)
W   # Watt (power)
Pa  # Pascal (pressure)
Hz  # Hertz (frequency)
V   # Volt (electric potential)

Physical Constants

Access common physical constants directly:

g  = 9.80665 m/s²     # Gravitational acceleration
c  = 299792458 m/s    # Speed of light
h  = 6.626e-34 J⋅s    # Planck constant
pi = 3.14159...          # Pi

Module System

Organize your code with imports and create reusable libraries:

# Import entire module
import constants
radius = constants.R_earth

# Import with alias
import math as m
result = m.sqrt(16)

# Import specific symbols
from physics import calculate_force, calculate_energy
force = calculate_force(10 kg, 9.81 m/s²)

Collections

Arrays

Arrays store homogeneous data with units and support mutation:

# Create and manipulate arrays
measurements = [10, 20, 30, 40] m
first = measurements[0]           # → 10 m
measurements[1] = 25 m              # Mutation supported
measurements[2] += 5 m              # Compound assignment

Dictionaries

Store key-value pairs with flexible keys and mutable values:

# Create dictionaries
material = {
    "density": 2700 kg/m³,
    "melting_point": 933.47 K
}

# Access and modify
density = material["density"]
material["density"] = 2710 kg/m³  # Update value