Vex is an easy-to-use, interactive command-line math evaluator and scripting language. It allows you to perform complex mathematical operations, define custom variables, and utilize a wide array of built-in constants and functions instantly from your terminal!
- Interactive REPL: A responsive loop (
Vex>) that instantly evaluates math expressions. - Variables: Assign results to variables (e.g.,
x = 5 * pi) and use the implicitansvariable which always holds your last result. - Constants: Pre-loaded with common math constants like
pi,e,tau, and the golden ratiophi. - Functions: Extensive suite of trig, logarithmic, rounding, and utility functions.
- Error Handling: Gracefully catches unknown variables, division by zero, and syntax errors.
You'll need a C compiler (gcc or clang) installed on your system.
Open your terminal in the project directory and run:
gcc main.c -o vexRun the compiled executable to start the Vex REPL:
./vexOnce inside Vex, you can type expressions exactly as you would write them mathematically.
Vex> 2 + 2 * (3^2)
= 20
Vex> 10 % 3
= 1
Variables can be whatever name you like.
Vex> radius = 10
= 10
Vex> area = pi * radius^2
= 314.159
Note: The ans variable is automatically updated and strictly holds the result of the last evaluated expression.
Use any of these within your expressions (e.g., sin(pi/2) or fact(5)):
| Trigonometry | Log/Exp | Other Math | Utilities |
|---|---|---|---|
sin(x), cos(x), tan(x) |
exp(x) |
sqrt(x), cbrt(x) |
fact(n) (Factorial) |
sind(x), cosd(x), tand(x) |
ln(x) |
ceil(x), floor(x), round(x) |
sign(x) |
asin(x), acos(x), atan(x) |
log(x) (base 10) |
abs(x) |
recip(x) |
sinh(x), cosh(x), tanh(x) |
log2(x) |
deg(x), rad(x) |
Type directly into the prompt to manage your session:
vars: Lists all currently defined variables and their values.funcs: Lists all built-in mathematical functions you can use.consts: Displays all available built-in mathematical constants.clear: Erases all user-defined variables (resets your session data without clearing terminal).exitorquit: Exits the Vex application.