davassi / yarer

Yarer is a library and a cli app for resolving mathematical expressions. Internally it uses the shunting yard algorithm.
https://github.com/davassi/Yarer
18 stars 1 forks source link

In what ways does yarer support RPN? #1

Open lunasophia opened 11 months ago

lunasophia commented 11 months ago

The README for this crate describes it as using RPN, yet the examples are all clearly using infix notation, and the README further states that the CLI tool works like GNU bc instead of GNU dc, which does use RPN. I am confused about what you mean by describing yarer as RPN.

davassi commented 11 months ago

Hi @lunasophia, thanks for pointing this out, sorry for the confusion. Yarer uses RPN internally to resolve and evaluate a mathematical expression, transforming it first from INFIX notation to RPN notation using the Shunting Yard algorithm. Essentially, it takes an infix notation as input and first transforms it into a postfix using the RpnResolver::reverse_polish_notation, and then resolves it using RpnResolver::resolve. About the CLI tool, you can start yarer as an executable, and feed it with infix notation math expressions, and it will resolve the expressions like GNU bc. Actually, it might be an interesting use-case to set a flag to allow only post-fix notation expressions to be evaluated. Hope this clarifies things.

xpe commented 11 months ago

I heard about your project from This Week in Rust and it got my interest. 💡

I'm here because the same confusion mentioned above jumped out at me as well. The above commenter (lunasophia) used a kind, curious phrasing which is all-too-often missing in Internet discussions, so kudos to them!

Caveats

I'm writing this because the Internet can seem to be a harsh place, and I don't want to contribute to that tone. So, I would like to add the following feedback, which I hope you can take in the spirit of editorial feedback described here

Writing is a vulnerable process. It’s something most of us do by ourselves, and after months or years of poring over a draft, the pages can start to feel like an extension of you as the writer. / It’s no wonder, then, that receiving a lengthy editorial letter filled with constructive criticism is difficult for some authors to swallow. They may perceive negative comments as an attack, even when the editor is delivering feedback that will ultimately improve the story.

I'm aware that I'm neither a professional editor nor your editor, but I hope my comments are useful nonetheless:

Editor-Style Feedback

When a reader first reads this they are likely to have cognitive dissonance for the reasons mentioned above:

Yarer (Yet another (Rusty || Rpn) expression resolver) is a flexible library,
written in Rust, for the processing, compilation and evaluation of
mathematical expressions using Reverse Polish Notation.

Example of usage of the library:
let session = Session::init();
let mut resolver = session.process("atan(cos(10+e)+3*sin(9/3))^2");

println!("The result is {}", resolver.resolve());

Such confusion can result in some people 'bouncing off' the README (and thus not giving it a try) or thinking less of it. We don't want that. I want all good open source projects to get their due consideration and be put to good use.

You only get a chance to make a first impression once. I think it would benefit you and your project to iterate on the README until it is perfectly clear what your library does.

Bottom line: thanks for creating this, sharing it, and opening yourself up to feedback.

davassi commented 10 months ago

@xpe Sorry for the late reply, I really and truly appreciate (and am impressed by) your deeply explained introduction and the problems you've pointed out. But, speaking for myself in the first person, I actually asked for feedback (as it's the best way to get sharp skills) so no need to be so diplomatic! I've changed the README to a much simpler form of communication. Hope this is better. Please feel free to contact me at gianluigi.davassi@gmail.com, would love to have a chat!