🛡️ Jarlang Standard Library
This page documents the functions and constants available in stdlib.vase for Jarlang.
Numeric Utilities
| Function | Signature | Description |
|---|---|---|
| max | max(a, b) | Returns the greater of two values. |
| min | min(a, b) | Returns the lesser of two values. |
| clamp | clamp(x, lo, hi) | Restricts x to the range [lo, hi]. |
| commune | commune(a, b) | Adds two numbers. |
| banish | banish(a, b) | Subtracts b from a. |
| rally | rally(a, b) | Multiplies two numbers. |
| slash | slash(a, b) | Divides a by b. |
| ascend | ascend(a, b) | Raises a to the power b. |
| circle_area | circle_area(r) | Calculates the area of a circle with radius r. |
| add1 | add1(x) | Increments x by 1. |
Advanced Numerics
| Function | Signature | Description |
|---|---|---|
| fact | fact(n) | Computes the factorial of n. |
| fib | fib(n) | Computes the nth Fibonacci number. |
| mean2 | mean2(a, b) | Returns the mean of a and b. |
| abs | abs(x) | Returns the absolute value of x. |
| sumTo | sumTo(n) | Returns the sum of all integers from 1 to n. |
| approx_equal | approx_equal(a, b, eps) | Checks if a and b are approximately equal within eps. |
| gcd | gcd(a, b) | Computes the greatest common divisor of a and b. |
| lcm | lcm(a, b) | Computes the least common multiple of a and b. |
| hypot | hypot(a, b) | Returns the hypotenuse for sides a and b. |
| pow_int | pow_int(a, n) | Raises a to the integer power n. |
| invert_sign | invert_sign(n) | Returns n with its sign inverted. |
| mod | mod(a, b) | Returns a modulo b. |
| sign | sign(x) | Returns -1, 0, or 1 depending on the sign of x. |
| sqrt | sqrt(x) | Returns the square root of x. |
| map_range | map_range(x, inMin, inMax, outMin, outMax) | Maps x from one range to another. |
| is_even | is_even(n) | Returns 1 if n is even, else 0. |
| is_odd | is_odd(n) | Returns 1 if n is odd, else 0. |
| is_prime | is_prime(n) | Returns 1 if n is prime, else 0. |
| deg2rad | deg2rad(d) | Converts degrees to radians. |
| rad2deg | rad2deg(r) | Converts radians to degrees. |
| abs_int | abs_int(x) | Returns the absolute value of x as an integer. |
| safe_lcm | safe_lcm(a, b) | Computes the LCM of a and b safely (handles zero). |
String Helpers
| Function | Signature | Description |
|---|---|---|
| concat | concat(a, b) | Concatenates two values as strings. |
| tale_repeat | tale_repeat(s, n) | Repeats string s n times. |
| barren_tale | barren_tale(s) | Returns 1 if string s is empty, else 0. |
Constants
| Name | Value | Description |
|---|---|---|
| KELVIN_OFFSET | 273.15 | Offset for Celsius to Kelvin conversion. |
| G_SI | 9.80665 | Standard gravity (m/s²). |
| G_CONST | 6.67430 × 10⁻¹¹ | Gravitational constant. |
| EARTH_MASS | 5.972 × 10²⁴ | Earth's mass (kg). |
Physics & Utility Functions
| Function | Signature | Description |
|---|---|---|
| potential_energy | potential_energy(m, h) | Calculates potential energy m * g * h. |
| celsius_to_kelvin | celsius_to_kelvin(c) | Converts Celsius to Kelvin. |
| kelvin_to_celsius | kelvin_to_celsius(k) | Converts Kelvin to Celsius. |
| orbital_period_years | orbital_period_years(a_AU) | Approximates orbital period in years for semi-major axis in AU. |
| orbital_period_seconds | orbital_period_seconds(a_meters) | Calculates orbital period (seconds) for radius in meters around Earth. |
| approx_equal_tol | approx_equal_tol(a, b) | Checks if a and b are approximately equal using a local tolerance. |