Skip to content

Math

For: advanced users computing in command lines.

One-arg reducers, two-arg blends, trig, easing, and aggregations, all accepting math in their arguments. The one-line forms live in the cheatsheet.

Tag Meaning
<min:a,b> The smaller number.
<max:a,b> The larger number.
<clamp:x,low,high> x clamped into range.
<floor:2.7> 2, rounds down.
<ceil:2.3> 3, rounds up.
<round:2.5> 3, rounds half up.
<abs:-4> 4.
<sign:-4> -1, else 0 or 1.
<sqrt:9> 3, square root (null for negatives).
<cbrt:-8> -2, cube root.
<cos:0> 1; <sin> and <tan> likewise take radians.
<arcsin:1> About 1.5708; inverse trig returns radians (null outside [-1, 1]).
<arccos:1> 0 (<acos> alias); <arctan:1> is about 0.7854.
<sec:0> 1; <csc> and <cot> are the other reciprocals.
<asec:2> About 1.0472; <acsc> and <acot> likewise invert.
<log:100> 2, base-10 (<log10> alias); <ln:10> is the natural log.
<easein:0.5> 0.25; <easeout:0.5> is 0.75, <easeinout:0.25> is 0.125.
<radtodeg:3.1416> About 180 (<r2d> alias).
<degtorad:180> About 3.1416 (<d2r> alias).
<atan2:1,1> About 0.7854, quadrant-aware arctangent of y,x.
<lerp:0,10,0.5> 5, linear blend (unclamped t).
<smoothstep:0,1,0.5> 0.5, Hermite blend with clamped x.
<smootherstep:0,1,0.5> 0.5, quintic blend with clamped x.
<sum:1,2,3> 6, total of one or more numbers.
<average:1,2,3> 2, mean (<avg> alias).
<median:1,3,2> 2, middle value (even counts average).
<pi> About 3.1416; <e> is about 2.7183.
<root:16,4> 2, the nth root of x.
<range:1,5> [1, 2, 3, 4], Python style.
<len:list> Item count, 0 when no list.
<format:"{0} found {1}",[Alex,gold]> Plain {n} substitution, silent on mismatch.

<min>, <max>, and <clamp> accept math in their arguments (<min:8+5,10> is 10) and yield 0 with a console warning when an argument is not a number. <floor>, <ceil>, <round>, <abs>, and <sign> also accept math (<floor:7/2> is 3), round halves up, and yield null with a warning when the argument is not a number. <sqrt:x> and <cbrt:x> follow the same one-arg rules (<sqrt:-1> is null with a warning; cube roots accept negatives), as do <cos>, <sin>, <tan>, <arccos> (<acos>), <arcsin> (<asin>), <arctan>, the reciprocals <sec>, <csc>, <cot>, the inverse reciprocals <asec>, <acsc>, <acot>, <log> (<log10>), <ln>, the quadratic easings <easein>, <easeout>, <easeinout>, <radtodeg> (<r2d>), and <degtorad> (<d2r>): trig takes radians, inverse trig returns radians (<arcsin:2> is null with a warning), <radtodeg:3.1416> is about 180, and <degtorad:180> is about 3.1416. <root:x,n> follows the two-arg rules: bad shapes, a zero index, and even roots of negatives yield 0 with a warning, while odd roots of negatives work (<root:-8,3> is -2). <atan2:y,x> is the quadrant-aware arctangent; <lerp:a,b,t> blends linearly with unclamped t, while <smoothstep:e0,e1,x> and <smootherstep:e0,e1,x> blend with clamped x (equal edges yield 0 with a warning). <sum:...>, <average:...> (<avg:...>), and <median:...> take one or more numbers, and <pi> plus <e> are constants. Comma-split tags (<sum>, <average>, <median>, <min>, <max>, <clamp>, the message and sound tags, <pstat>, <pcountitem>) split on every comma outside quotes, blind to nested tags: quote values that may hold commas, and hoist a nested comma-tag into <lf> first (<min:<list.get:x,1>,2> fails validation as three apparent args; stage it through <lf:v>).

Next Steps