-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Literals can be specified using different representations.
3
0xFF
0b110
3.123
.123
Scientific notation can be used to input big numbers more easily.
1e2
3e5
funcially supports using objects which encapsulate more complex data structures. Objects always follow the syntax:
{<name> <args>}
.
The following objects can be used:
Name | Syntax |
---|---|
date |
{date now} / {date <day>.<month>.<year>} 1
|
1: This format can be changed in the settings.
Name | Operator |
---|---|
Addition | + |
Subtraction | - |
Multiplication | * |
Division | / |
Name | Operator |
---|---|
Exponentiation | ^ |
Bitwise AND | & |
Bitwise OR | | |
Left Shift | << |
Right Shift | >> |
Modulo | mod |
Taking a percentage of a number | of |
Unit conversion | in |
Modifiers are similar to operators, except that they only have one operand.
They change the value of what they were pre- or appended to.
Name | Modifier | Long form |
---|---|---|
Percent | % |
n / 100 |
Bitwise NOT |
! (prepended) |
- |
Factorial |
! (appended) |
n * (n - 1) * ... * 1 |
20%
!0b101
5!
(50 / 2)%
- Functions and variables
- Groups ("(...)")
- Extended operators
- Multiplication and division
- Addition and subtraction
-
of
andin
The multiplication sign can be left out in the following scenarios:
- Before variables
- Before functions
- Before groups
2pi
2sin(30)
2(3 + 4)
(3 + 4)(1 + 2)
Trigonometric functions use parameters in radians and their inverse functions also return values in radians.
To use degrees, simply convert the units:
sin(30°)
asin(.5) in °
Description | Function | Example |
---|---|---|
Sine | sin | sin(1) |
Arcsine | asin | asin(.5) |
Cosine | cos | cos(1) |
Arccosine | acos | acos(.5) |
Tangent | tan | tan(1) |
Arctangent | atan | atan(.5) |
Cotangent | cot | cot(1) |
Arccotangent | acot | acot(.5) |
Natural logarithm | ln | ln(3) |
Logarithm | log(base, n) | log(2, 8) |
Square root | sqrt | sqrt(25) |
Cube root | cbrt | cbrt(1000) |
Root | root(index, n) | root(2, 8) |
Absolute value | abs | abs(-10) |
Flooring | floor | floor(3.5) |
Lerping | lerp(a, b, t) | lerp(0, 50, .5) |
Ceiling | ceil | ceil(20.2) |
Clamping | clamp(n, start, end) | clamp(5, 0, 2) |
Map from one range to another | map(n, start1, end1, start2, end2) | map(5, 0, 10, 20, 100) |
Rounding (optional decimal places) | round(n) / round(n, <decimal places>) |
round(5.2) / round(5.123, 2)
|
Syntax: name(arg1, arg2, ...) := expr
A custom functions is defined with a name, a set of arguments separated by commas and an expression that evaluates to
the function's value. In the expression, the names given to the arguments before the definition sign (:=
) can be used.
As such, this expression cannot be evaluated right away.
If "expr" is empty, the function is removed.
When a function is re-declared (i.e. the function already exists), one of two things happens:
- If the function being declared is a standard function (e.g.
sin
), an error occurs, saying that standard functions cannot be overridden. - Otherwise, the function's expression and arguments are updated.
The same applies when removing a function.
f(x) := x * 3
f(x, y) := x ^ y
f(x, y) :=
Constant | Value |
---|---|
pi | 3.1415926536 |
e | 2.7182818285 |
tau | 6.2831853072 |
The ans
variable contains the result of the previous calculation. It starts out at 0.
Syntax: name := expr
A custom variable is defined with a name, and an expression that resolves to its value. When the variable is declared, its expression is evaluated and the result (including an optional unit) is stored for future use. Variable do not store formats.
If "expr" is empty, the variable is removed.
When a variable is re-declared (i.e. the variable already exists), one of two things happens:
- If the variable being declared is a builtin variable (e.g.
pi
), an error occurs, saying that standard variables cannot be overridden. - Otherwise, the variable's value is updated.
The same applies when removing a variable.
x := 4 + 3
pi := 4 => Error: ReservedVariable
x := 20 * 2
x :=
An equals sign ("=") marks this line as an equality check. funcially then returns True
or False
, depending on whether
the two expressions evaluate to the same value (including units).
The equals sign must be at the top level and there can only be one equals sign in a line.
20 + 30 = 25 * 2
20 * 5 = 10
funcially can solve linear equations if there is a question mark (?
) in either sides.
- There can only be one question mark in an equation.
- The question mark can only be a function argument of custom functions that are themselves linear.
If the question mark is preceded by a variable name, its calculated value will be assigned to the given variable.
30 + ? = 100
? * sin(30) = 1 + 1
20 + x? = 100.5
Units are defined with a name and an optional unit prefix.
Units and unit prefixes are case-sensitive.
Prefix | Name | Value |
---|---|---|
n |
Nano | 1e-9 |
m |
Milli | 1e-3 |
c |
Centi | 1e-2 |
d |
Deci | 1e-1 |
h |
Hecto | 1e2 |
k |
Kilo | 1e3 |
M |
Mega | 1e6 |
G |
Giga | 1e9 |
T |
Tera | 1e12 |
P |
Peta | 1e15 |
E |
Exa | 1e18 |
Z |
Zetta | 1e21 |
Y |
Yotta | 1e24 |
Unit prefixes can be used without a unit and thus act like a modifier (e.g. 3k = 3000
).
Numbers with and without units can be mixed, resulting in the unit being carried to the result.
If the line consists only of a literal with a unit, the unit in the result is printed in it's long form. Otherwise,
the abbreviated version is used.
Two units can be combined using a /
in between.
funcially will automatically convert units to perform operations if needed. In that case, the right hand side's is converted into the left hand side's unit.
10m
10km/h
(10 + 10)km
20 * 2min
funcially supports currencies from exchangerate.host, like EUR
or USD
.
These can be used the same way as units. funcially updates the exchange rates on every startup and saves them
for when there is no internet connection available.
Syntax: <expr> in <decimal/binary/hex>
This is valid everywhere in a line, but only has an effect if it is at the end.
If the left hand side has a unit, the unit's number is converted and the unit is kept.
0xFF in decimal => 255 (default)
255 in hex => 0xFF
6 in binary => 0b110
255km in hex => 0xFF Kilometers
There are some settings, which allow the user to customize funcially to their preferences.
The settings can be accessed via File>Settings
in the GUI, or via the set
and get
commands in the CLI.
Syntax: set <setting> = <value>
, get <setting>
A setting is always specified by a "path", delimited by dots.
For both, a question mark behind <setting>
may be used to list available settings (e.g. set ?
or set date ?
).
Other features:
- Saving: The input field's text is saved across restarts
- Syntax highlighting
- Installation with installers
- Available on Desktop and Web. The web version can be downloaded to be available offline, and can thus be used on e.g. Android tablets
- Searching
Calculations can be annotated using comments. Comments start with #
and span the entire rest of the line.
# This is a comment spanning the entire line
3 + 4
sin(30)
20% of 100 # This gives more details about the calculation
The GUI supports plotting single argument functions. When declaring a single argument function, a checkbox appears in the output column, allowing the function to be selected to show in the plot. The plot can be brought up via the button in the top right ("🗠 Plot").
If there are multiple re-declarations of a function, each re-declaration can be shown individually.
"Cmd" is ctrl
on Windows and Linux and ⌘
on macOS.
Description | Shortcut |
---|---|
Comment/Uncomment selected lines | Cmd+Alt+N |
Surround selection with parentheses | Cmd+B |
Copy result of current line | Cmd+⇧+C |
Format input text | Cmd+Alt+L |
Search | Cmd+F |
Go to line | Cmd+G |