bbodi / notecalc3

NoteCalc is a handy calculator trying to bring the advantages of Soulver to the web.
https://bbodi.github.io/notecalc3/
GNU Affero General Public License v3.0
1.16k stars 43 forks source link

Providing a REPL / single input single output library functionality ? #42

Open lollita opened 2 years ago

lollita commented 2 years ago

Do it is possible to have a isolated function or library that parse the line and return the result? also in wasm. f.e. parse("calc = 5k + 4k"); that return 9 kg

bbodi commented 2 years ago

Hi,

Yes, as you can see, notecalc-lib is a separate library, so you can include it in your app and feed any string into it. You can find some examples in the benchmark folder (benchmarks were implemented as a binary crate using notecalc as a library, the same way as your wished feature).

Though, the ergonomics are not the best, since the notecalc lib handles text editor and other functionalities as well, also one of the strength of notecalc is being a multilne calculator, referencing other lines in your formula, or calculating averages or sums of many lines.

lollita commented 2 years ago

Of course, I saw it. But inside there are very things and it is difficult to isolate you only the routine that seemed the calculations and generally use it in another context.