Commit Graph

318 Commits

Author SHA1 Message Date
bakk
22488f1f38 Added tests for prelude functions 2021-05-25 21:29:59 +02:00
bakk
87df8df12a Support syntax like sin2x 2021-05-24 22:32:33 +02:00
bakk
643b92c23d Support syntax like sinxdx in integrals 2021-05-24 22:05:35 +02:00
bakk
f944e3cebc Keep previous variable value after integration using the same identifier 2021-05-24 21:51:25 +02:00
bakk
c4c768374f Made recursion possible 2021-05-24 21:32:58 +02:00
bakk
d1365b5982 Round result slightly to get a more 'lagom' amount of decimals 2021-05-24 18:22:03 +02:00
bakk
e40428016f kalk v2.0.0 2021-05-23 18:43:22 +02:00
bakk
04644dc54f Added tests for kalk_num estimation, rounding, and to string functions 2021-05-23 18:17:19 +02:00
bakk
9e0c6a732b abs() the imaginary value on to_string(), since the sign is already there 2021-05-23 16:08:25 +02:00
bakk
eaf712e01f Added tests for calculus.rs 2021-05-23 15:58:23 +02:00
bakk
33de7f034c Fixed rounding for complex numbers resulting in 0 2021-05-23 15:04:12 +02:00
bakk
b0a1d3581b Integration with complex numbers 2021-05-23 02:21:35 +02:00
bakk
ab6e758726 Allow a comma before 'dx' in integrals 2021-05-23 01:56:25 +02:00
bakk
0e425fbf90 Allow function calls without parenthesis even with a variable as argument 2021-05-23 01:42:10 +02:00
bakk
7fd6d28e1d Always round values <= 10^-16 down to zero 2021-05-23 01:30:10 +02:00
bakk
0bbf1c4974 Finding square roots for estimate() 2021-05-23 01:10:22 +02:00
bakk
34e374b346 Created synonym 'integral' for 'integrate' 2021-05-23 00:55:35 +02:00
bakk
7b635079c8 Fixed estimation skipping values with no estimation, when the real/complex value had an estimation 2021-05-23 00:52:43 +02:00
bakk
c80f58433c Convert fract to f64 before turning into string in estimate() 2021-05-23 00:44:58 +02:00
bakk
7af71ff332 Avoid panic because of invalid number literal 2021-05-23 00:04:50 +02:00
bakk
594d139345 Fixed integration with expressions like xdx 2021-05-22 23:59:53 +02:00
bakk
a60dc2bf65 Fixed eg. 'xy' being parsed as 'y' inside functions 2021-05-22 22:40:24 +02:00
bakk
cff40be924 Made sum() and ans compatible with complex numbers 2021-05-22 22:03:35 +02:00
bakk
637c3e331b Implemented complex variants of prelude functions 2021-05-22 20:47:10 +02:00
bakk
7898f40021 Adjusted estimation and rounding to include imaginary numbers 2021-05-20 20:50:24 +02:00
bakk
328810d29d Division with complex numbers 2021-05-20 19:50:59 +02:00
bakk
ee3082ad66 Made complex numbers work without rug 2021-05-20 19:26:03 +02:00
=
22ac36bb4a Fixed negative scientific notation 2021-05-20 15:19:26 +02:00
=
2936a58620 Basics of complex numbers 2021-05-20 15:11:32 +02:00
=
869708b454 Removed code duplication in kalk_num 2021-05-20 11:03:53 +02:00
PaddiM8
d21202a446 kalk_web: Fixed error on empty result 2021-05-19 09:45:19 +02:00
bakk
150a0c7632 v0.4.1 2021-05-18 23:23:01 +02:00
bakk
4c92062117 Use KalkNum's to_string() function in to_scientific_notation() 2021-05-18 23:20:23 +02:00
bakk
121aafa118 kalk_web: Added integral and estimation support 2021-05-18 23:08:38 +02:00
bakk
e04742695a Combined to_scientific_notation() methods for both types, and added tests 2021-05-18 23:03:21 +02:00
bakk
cc776367fa Added wasm binding to KalkNum.estimate() 2021-05-18 20:40:43 +02:00
bakk
93830090b5 Bumbed version to 0.4.0 2021-05-18 20:34:17 +02:00
bakk
09c99c9169 Fixed mod.rs errors for when rug is not used, and added some unit tests there 2021-05-18 20:02:21 +02:00
bakk
dea2ab9ee2 Estimation/rounding for final results 2021-05-18 19:48:13 +02:00
bakk
2636f51077 Lex special symbols as one token 2021-05-18 17:49:31 +02:00
bakk
4db84aa441 Basic rounding for calculus functions 2021-05-17 23:55:20 +02:00
bakk
7f32829921 Higher order derivatation 2021-05-17 23:09:59 +02:00
bakk
ff6ad6a10d Improved accuracy for derivation 2021-05-17 21:27:11 +02:00
bakk
15c30cfeee Basics of derivation
Derivation implemented for function calls (only). Eg. f'(2). It is not
yet possible to do something like f''(2), but this should be implemented
in the future. It should also be possible to derive normal expressions,
but this is not yet possible.
2021-05-17 20:36:53 +02:00
bakk
9acdd71589 Created 'Identifier' struct that contains prime count and name without primes (ticks ') 2021-05-17 20:17:34 +02:00
bakk
374a449eab Fixed integrate function test 2021-05-17 18:15:49 +02:00
bakk
0c454fb6f4 Lex '**' as power sign 2021-05-17 18:14:48 +02:00
bakk
48e94b1cdb Switched to Simpson's rule (composite, 3/8) for integration 2021-05-17 18:05:22 +02:00
bakk
08617640a5 Fixed "dx" in integrals, and created calculus.rs
Previously, eg. "dx" would not be parsed as "dx" after a function, since
the parser did not keep track of whether or not it was currently inside
an integral or not, properly. This commit fixes that, and also makes it
possible to use any variable after the "d", eg. "dy". The integration
function was also put in its own file: calculus.rs.
2021-05-17 16:51:16 +02:00
bakk
1d9237d30d Integration estimation
Needs more a bit more accuracy though. Currently the n value in the
trapezoidal rule is fixed.
2021-05-16 15:15:34 +02:00
bakk
4cfd563b38 kalk_web: Updated kalk and fixed audit problems 2021-05-15 17:22:18 +02:00
bakk
d5c991ffdf Fixed zeroes being trimmed for non-rug numbers 2021-05-15 16:15:25 +02:00
PaddiM8
277b1ed4c0 Updated the kalk version in web related things 2021-03-31 22:10:05 +02:00
PaddiM8
4751bbffe0 kalk: Fixed type error in kalk_num/regular.rs 2021-02-22 21:21:43 +01:00
PaddiM8
561bd61c3f Trimming trailing zeroes for non-rug numbers 2021-02-22 20:45:58 +01:00
PaddiM8
31878f9f1f Fixed xy^z precedence, from (xy)^2 to x(y^2) 2021-02-22 20:27:42 +01:00
Oliver Waldemar
ecc0fd5dcf Created kalk_mobile capacitor app with android and electron targets 2021-01-07 16:34:55 +01:00
PaddiM8
93514906f3 v0.3.12 2021-01-04 18:01:03 +01:00
PaddiM8
2714ed0f8c Fixed gamma and factorial functions for f64 2021-01-04 17:49:11 +01:00
PaddiM8
9de16e0fbe Fixed semantic errors 2021-01-03 00:19:22 +01:00
PaddiM8
a84e1e6527 kalk 1.4.1 2021-01-03 00:10:58 +01:00
PaddiM8
dd63bace58 Removed regex dependency from kalk crate and made 'test-case' a dev-dependency 2021-01-03 00:07:30 +01:00
PaddiM8
0c802df3d5 Implemented prelude gamma function for kalk without rug 2021-01-02 19:25:10 +01:00
PaddiM8
1df4932e25 Changed to a more recent version of wasm-pack (ci), and added optimization to wasm 2021-01-02 01:00:54 +01:00
PaddiM8
416064ac53 v0.3.10 and added npm publishing to ci 2021-01-01 17:44:56 +01:00
PaddiM8
bf06c7789d Updated kalk library README to include a JavaScript example, disabled wasm optimization, and created wasm build script 2020-12-31 01:47:09 +01:00
PaddiM8
f81e1731b3 Moved js_eval into Context 2020-12-31 01:03:16 +01:00
PaddiM8
3fc5a71b34 Return Option from js_eval 2020-12-31 00:16:39 +01:00
PaddiM8
b59d3e1f51 JavaScript bindings to KalkNum and ScientificNotation 2020-12-31 00:15:16 +01:00
PaddiM8
8a30ee7163 Added ToString trait to CalcError enum 2020-12-30 22:54:32 +01:00
PaddiM8
efbeb0857f WebAssembly foundation 2020-12-30 22:50:39 +01:00
PaddiM8
8014a61f1a Created a cargo feature for rug, f64 will be used instead if it's disabled 2020-12-30 16:03:02 +01:00
PaddiM8
e8c362c72e Prevent self-referencing variables 2020-12-28 23:54:12 +01:00
PaddiM8
865947dccd Improved consonant precision 2020-12-28 23:06:53 +01:00
PaddiM8
6518194582 v0.3.9 2020-12-28 19:15:25 +01:00
PaddiM8
17f5a0604e Fixed function declarations not being parsed 2020-12-28 19:13:39 +01:00
PaddiM8
b7153d68b7 Interpretation timeout 2020-12-28 19:09:21 +01:00
PaddiM8
58bb2fd60f Simple equation solving, mostly using pre-existing logic from the inverter 2020-12-14 19:21:30 +01:00
PaddiM8
9cacb0c57a v0.3.8 2020-12-14 00:07:19 +01:00
PaddiM8
7c05d1ab22 Added sum function to symbol_table::contains_fn 2020-12-13 23:47:44 +01:00
PaddiM8
fd29599e31 Fixed bug where symbol_table::contains_fn didn't check in the BINARY_FUNCS map 2020-12-13 23:44:33 +01:00
PaddiM8
98d29bcaa6 v0.3.7 2020-12-13 23:17:49 +01:00
PaddiM8
912779811c Allow multiplication with parenthesis without star symbol 2020-12-13 23:16:47 +01:00
PaddiM8
c92512d79d Added 'Copy' to TokenKind, and added a missing line related to the sum function 2020-12-13 22:09:49 +01:00
PaddiM8
339d98e2c6 User-configurable precision 2020-12-13 18:12:33 +01:00
PaddiM8
1233ad4269 Optimised 'sum' function 2020-12-13 17:45:06 +01:00
PaddiM8
a1af433ebd Allow spaces in input number literals 2020-12-13 16:44:45 +01:00
PaddiM8
6d8e182578 Fixed constant rounding 2020-12-13 15:53:38 +01:00
PaddiM8
c6d75104b3 Store number literals as f64 2020-12-13 15:52:22 +01:00
PaddiM8
c7b0b27117 Moved some unit logic into kalk_num 2020-12-13 15:31:11 +01:00
PaddiM8
98014166a9 Trimming zeroes at the start of scientific notation, and scientific notation exponent value fix 2020-12-13 02:25:33 +01:00
PaddiM8
9212581ebd Fixed tests 2020-12-13 02:11:19 +01:00
PaddiM8
f29104e489 Created KalkNum and moved output formatting from kalk_cli to kalk 2020-12-13 01:27:55 +01:00
PaddiM8
b6a745edbb removed un-used rug features 2020-12-11 13:17:33 +01:00
PaddiM8
29f8ac94f3 replaced phf with lazy_static 2020-12-10 23:40:29 +01:00
PaddiM8
3836d6e326 updated test_percent() 2020-12-10 15:13:02 +01:00
PaddiM8
e0384d3653 fixed multiplication with percent 2020-12-10 09:27:19 +01:00
PaddiM8
dd1b4d723f added percentage unit and modulo 2020-12-09 22:18:00 +01:00
PaddiM8
4d17210b49 allow letters after underscore in variables, eg. x_a 2020-12-09 10:47:46 +01:00
PaddiM8
ee6a4066da updated to 0.2.1 2020-12-09 09:40:26 +01:00
PaddiM8
f322bcbc7d fixed panic on trailing spaces 2020-12-09 09:36:49 +01:00
PaddiM8
1d93e60d91 Made lexer lex '°' as 'deg'. 2020-06-18 18:06:17 +02:00
PaddiM8
fe6df0ff32 Fixed merge issues, updated version numbers, and updated README with syntax instructions. 2020-06-18 18:03:40 +02:00
PaddiM8
d041a28f1d Merge branch 'units' 2020-06-18 17:42:36 +02:00
PaddiM8
3b492f5119 Added units to prelude functions. 2020-06-18 17:41:57 +02:00
PaddiM8
5de759b56b Fixed parser documentation and interpreter units tests. 2020-06-18 17:06:21 +02:00
PaddiM8
ce824511ff Created unit convertion expression. Syntax: <expr> to <unit> 2020-06-18 16:58:01 +02:00
PaddiM8
3259e78597 Changed nth_sqrt to nth_root. 2020-06-18 16:20:52 +02:00
PaddiM8
07e34c6bbb Implemented inversion for some prelude functions. 2020-06-18 16:20:18 +02:00
PaddiM8
7d845523d8 Made the unit be displayed in the result. 2020-06-18 02:02:48 +02:00
PaddiM8
8adabaa992 Added UnsupportedExpression errors. 2020-06-17 21:28:54 +02:00
PaddiM8
aa449ee92b Fixed inversion for (function) variables and added unit tests for the inverter. 2020-06-17 17:45:46 +02:00
PaddiM8
99fbdd6883 Fixed the broken unit tests in the parser and completed the test_angle_units test in the interpreter. 2020-06-15 21:27:47 +02:00
PaddiM8
7f3fb7c045 Integrated the angle unit system with then new dynamic unit system. 2020-06-15 19:10:55 +02:00
PaddiM8
7b708a7b45 Updated README with new features and updated version numbers. 2020-06-14 22:53:11 +02:00
PaddiM8
b87b2d10bc Added ans variable. 2020-06-14 22:33:29 +02:00
PaddiM8
20f15619a2 Added semicolon support to combine several statements in one line. 2020-06-14 22:03:22 +02:00
PaddiM8
112d8e78ea Added support for 'minus' expressions in the inverter and added some comments. 2020-06-14 21:54:39 +02:00
PaddiM8
a81cef2a86 Added support for 'minus' expressions in the inverter and added some comments. 2020-06-14 21:35:56 +02:00
PaddiM8
24771b3a5a Changed inverter to instead move expressions to the LHS, like done when equations are solved in maths. Also made it multiply into parenthesis. 2020-06-14 19:23:02 +02:00
PaddiM8
1edec7d16e Added some error checking to the inverter. 2020-06-13 22:18:37 +02:00
PaddiM8
e6778f7ef5 Merge branch 'master' into units 2020-06-13 21:57:27 +02:00
PaddiM8
c50534a248 Publish. 2020-06-13 21:42:14 +02:00
PaddiM8
d042e3577f Made it possible for the inverter to invert expressions with function calls. 2020-06-13 20:06:21 +02:00
PaddiM8
bff785bc1e Created the foundation of an expression inverter. This is used to create a second *inverted* unit declaration, in order to cover both of the units. 2020-06-13 19:01:33 +02:00
PaddiM8
eb20aae16f Added the unit statement (very basic and experimental). 2020-06-13 16:19:32 +02:00
PaddiM8
430841fc5f Trimmed end matches of dots in order to avoid numbers such as 1.. 2020-06-12 21:30:03 +02:00
PaddiM8
2cffe8dbfa Updated crate versions (thought I did this in the previous commit??). 2020-06-12 21:27:01 +02:00
PaddiM8
bbea1e4e82 Merge branch 'master' of https://github.com/PaddiM8/kalk 2020-06-12 21:01:12 +02:00
PaddiM8
db60867a19 Changed kalk crate version. 2020-06-12 21:00:56 +02:00
PaddiM8
52ad501ba3 Updated example code in README. 2020-06-12 21:00:03 +02:00
PaddiM8
6711e22f3e Version update test. 2020-06-12 18:16:54 +02:00
PaddiM8
f2a1ddcc05 Updated .travis.yml. 2020-06-12 16:10:32 +02:00
PaddiM8
0a5130099b Created a workspace Cargo.toml to unify the library and binary. 2020-06-12 14:11:42 +02:00
PaddiM8
fbe72d3f55 Fixed code in documentation in parser.rs 2020-06-12 14:10:10 +02:00
PaddiM8
8b16e3cbd4 Added example image and expanded feature list. 2020-06-12 00:34:50 +02:00
PaddiM8
50ba5f4d18 Added readme to Cargo.toml. 2020-06-12 00:08:14 +02:00
PaddiM8
22c5b0785c Added separate readme for the library. 2020-06-12 00:06:54 +02:00
PaddiM8
122aca4a97 Added separate readme for the library. 2020-06-12 00:06:15 +02:00
PaddiM8
0dc5bf9d30 Changed version number to 0.1.1 2020-06-11 23:53:04 +02:00
PaddiM8
9bf5ac209b Changed 'parsers' category to 'parser-implementations' 2020-06-11 23:52:12 +02:00
PaddiM8
cb1a7e921c Changed Cargo.toml to prepare for publish. 2020-06-11 23:47:03 +02:00
PaddiM8
4f9f8bc63e Extended parser::eval and parser::parse documentation by explaining when None is returned. 2020-06-11 23:45:54 +02:00
PaddiM8
46a27d4129 Added simple documentation for the exposed parts. 2020-06-11 23:09:44 +02:00
PaddiM8
0274721878 Added test_undefined_fn for the interpreter. 2020-06-11 22:14:43 +02:00
PaddiM8
125499065a Added test_fn and test_sum_fn for the interpreter. 2020-06-11 22:10:23 +02:00
PaddiM8
ffd26c1da9 Renamed symbol_table::contains_func to contains_fn. 2020-06-11 21:47:14 +02:00
PaddiM8
4fbb71f423 Made the ast module public. 2020-06-10 14:02:33 +02:00
PaddiM8
3ffd62c572 Renamed parser::parse to parser::eval and created a new parser::parse function that does not evalutate the statements. 2020-06-10 13:55:43 +02:00
PaddiM8
9ab0abf1b5 Added gamma function. 2020-06-09 20:50:05 +02:00
PaddiM8
98fc2bf151 Made the x_1 notation possible. 2020-06-09 14:59:29 +02:00
PaddiM8
995897fc25 Fixed lexer not ignoring whitespace properly. 2020-06-09 10:34:39 +02:00
PaddiM8
165df6d3f3 Changed lexer source to a peekable iterator, resulting in (hopefully) proper UTF-8 support. 2020-06-08 21:51:45 +02:00
PaddiM8
42524eefa3 Somewhat fixed UTF-8 support in the lexer. 2020-06-07 19:48:52 +02:00
PaddiM8
f6b7dce791 Added position data to tokens. 2020-06-06 20:15:32 +02:00
PaddiM8
aeed8049fc Fixed output not displaying small-ish decimal numbers properly. 2020-06-06 17:20:40 +02:00
PaddiM8
d0536d6bd6 Created CalcError enum and centralised error formatting into once place. 2020-06-06 16:28:48 +02:00
PaddiM8
4a02134b22 Added unit tests for unit, var, undefined var, and var decl for the interpreter. 2020-06-06 15:39:34 +02:00
PaddiM8
3fda01e087 Added unit tests for literal, binary, and unary for the interpreter. 2020-06-05 21:57:20 +02:00
PaddiM8
2bacbf5c67 Added unary expression unit test for the parser. 2020-06-05 19:03:16 +02:00
PaddiM8
f1d09ae799 Changed lexer to allow whitespace between number literal. 2020-06-05 17:18:36 +02:00
PaddiM8
e7cbbc45c2 Removed test_case from test_pow(). 2020-06-05 16:20:50 +02:00
PaddiM8
dab1006eb7 Added pow, var_decl, fn_decl, fn_call unit tests for the parser. 2020-06-05 16:18:29 +02:00
PaddiM8
98d4a16195 Cleaned up redundant code and replaced compare_enums() with PartialEq. 2020-06-05 13:47:39 +02:00
PaddiM8
4360f3f4ee Set up foundation for parser unit testing and added test_var() and test_precedence() tests. 2020-06-05 13:36:11 +02:00
PaddiM8
0d33efbf63 Added unit tests for lexer. 2020-06-04 21:53:45 +02:00
PaddiM8
3a8e939ac0 Removed self.advance() code duplication in lexer. 2020-06-04 20:09:43 +02:00
PaddiM8
cbc0b340a1 Renamed to 'kalk'. 2020-06-04 19:43:43 +02:00