140ce061a3
test: add real world example
...
this is what failed before the last fix;
it was formatted to "0.-125"
2026-11-18 19:24:59 -08:00
c2b91fb774
refactor: put back format!
...
I think this is still a little nicer to read
2026-11-18 19:24:25 -08:00
Edeth-Baguette
4a8a08f66a
fix: account for negative sign
2026-11-18 19:16:39 -08:00
667f2e8eeb
refactor(formatting): no premature optimization
2026-11-16 15:27:31 -08:00
aef4b4727a
refactor(formatting): use helper function
...
this is probably much more efficient,
since `"0".repeat(n)` allocates a new string
(which is then immediately deallocated)
2026-11-16 15:08:56 -08:00
7a1049fda9
docs(formatting): add note
2026-11-15 21:39:59 -08:00
f60c8749a0
refactor(formatting): remove unneeded logic
2026-11-15 21:23:20 -08:00
Edeth-Baguette
42692d3ae4
feat: add (fully?) working sci notation correcter
2026-11-15 21:09:18 -08:00
24b665ed29
docs: remove fixed behavior from unfinished list
2026-11-15 19:30:13 -08:00
56d5f7bd06
refactor: simplify min and max digits
...
min and max methods are pretty confusing, this is much nicer.
2026-11-15 19:15:35 -08:00
6980655714
fix: do unary operators after function evaluation
2026-11-15 17:13:21 -08:00
f87bb5903f
docs: add readme
2026-11-14 18:01:37 -08:00
dc6bdcf3ac
feat: add factorial function
...
this isn't perfect, and it doesn't exist in typst,
but at least it exists now.
the problem is switching away from very basic operators
and very basic functions requires a lot of work
(many changes to both evaluation and parsing)
2026-11-13 16:02:22 -08:00
4ffe6c8d0f
build: add statically linked output
...
if only something like this was possible with wayland and others...
2026-11-10 14:43:37 -08:00
b4f0b81d9b
refactor: simplify devshell
...
inputFrom already inherits cargo and rustc
(from the rustPlatform used in the bin package)
2026-11-10 14:13:01 -08:00
f05eb164cd
refactor: rename derivation binding (crate -> bin)
2026-11-10 13:45:53 -08:00
8553f5efd9
build: optimize flake
2026-11-10 13:43:26 -08:00
c9d85459f3
feat: add way more functions
2026-11-04 15:00:06 -08:00
4eb6f55f9a
feat: add abs function
2026-11-04 14:10:34 -08:00
b7ce85c3f4
feat: support "arcsin" way of writing inverse trig
2026-10-31 17:00:25 -07:00
c483a4dce8
fix: missing implicit operator
...
(0.2)20^2 was missing a mult and caused a crash,
even though (0.2)20 was just fine.
2026-10-24 16:15:13 -07:00
c74abdace3
fix: ignore underscore in input
...
I accidentally removed this before... oops :3
2026-10-23 22:18:05 -07:00
f1f9c11a04
feat: use more precise pi
...
with pretty_eval, I still get:
-9.194801691 * 10^-618
but at least that's more accurate than the prior:
1.224646799 * 10^-16
2026-10-20 21:27:40 -07:00
0ede27e927
refactor: rename confusing index variable
2026-10-20 19:26:14 -07:00
9bd0318702
refactor: make Operator/Function ordering consistent
2026-10-20 18:00:08 -07:00
56e8fbca99
refactor: nicer operator/function eval functions
2026-10-20 17:58:57 -07:00
570da21956
refactor: replace duplicate eval code with macro
2026-10-20 17:42:50 -07:00
7182e29512
fix: correctly evaluate unary operators with parenthesis
2026-10-20 16:53:26 -07:00
a520177183
feat: parse unicode pi, π
2026-10-19 17:46:02 -07:00
780f0c6f4c
refactor: create macro assert_pretty_eval
...
this makes the tests so much shorter in the code, it's nice
2026-10-19 12:24:52 -07:00
9794e0c9d5
refactor: maybe more efficient rsplit_once_last
2026-10-19 00:21:32 -07:00
e23327c08f
refactor: loosen lifetime bounds
2026-10-19 00:19:35 -07:00
0f937fe9a8
fix(formatting): split on last match
...
the implementation doesn't look very performant,
since it calls rfind and then rsplit_once.
using split_at to replace the second call is a little more difficult tho
2026-10-19 00:18:05 -07:00
58b3d876e4
fix: constant implicit mult
...
before, "pi 2" caused a panic while "2 pi" worked just fine.
now both directions work :)
2026-10-18 22:30:39 -07:00
475c30b1a9
fix(formatting): don't count minus as digit
2026-10-18 22:14:57 -07:00
12455924e1
refactor: create constant for tests
2026-10-14 16:52:07 -07:00
702cf74647
feat: generalize splitting for plus.minus
2026-10-14 16:50:51 -07:00
2d6f03c28c
build: update flake (late commit)
2026-10-09 18:57:26 -07:00
5cdfbfea5e
refactor: avoid extra owned string
...
I think this is more readable, too
2026-10-09 18:53:02 -07:00
acc49edd31
feat: generalize removing and adding back prefix
2026-10-09 18:50:19 -07:00
da82532361
refactor(formatting): move tests into module
2026-10-09 16:20:04 -07:00
046a3e5b20
feat: ignore underscores in input
...
this isn't useful for typst usually,
since underscores are subscript and don't appear in expressions much.
however, when using tylc as a standalone calculator,
this is useful eg to seperate sets of three digits.
idea totally stolen from rust literals
note that this might cause problems when it comes to special variables,
eg A_n for Avogadro's number (but just A is fine)
2026-10-09 16:10:32 -07:00
bb985f917a
refactor: create submodules for tests
2026-10-06 16:21:18 -07:00
00dfcdb10c
fix: do not panic with zero-sized result
2026-10-06 16:17:02 -07:00
3745b655ba
refactor: factor out function aquisition
2026-10-06 15:56:10 -07:00
69d8d111ba
refactor: improve eval error handling (end)
...
now most of the panics come from Vec::remove,
which can be fixed with Vec::try_remove when it's stabolized
2026-10-06 15:49:16 -07:00
d6b775abfb
refactor: improve eval error handling (start)
2026-10-06 15:49:07 -07:00
3d4e9d8067
fix: recognize unary operators at ParenthesisStart
2026-10-06 12:30:13 -07:00
f1c6073708
feat: add ln function
...
this one is easier than log or root, because it only takes one arg
2026-10-06 11:51:04 -07:00
e59f928192
refactor: simplify input logic
2026-10-04 16:45:48 -07:00