notecalc3 icon indicating copy to clipboard operation
notecalc3 copied to clipboard

Providing a REPL / single input single output library functionality ?

Open lollita opened this issue 3 years ago • 2 comments

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

lollita avatar Mar 24 '22 21:03 lollita

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.

bbodi avatar Mar 25 '22 19:03 bbodi

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.

lollita avatar Mar 25 '22 19:03 lollita