PaddiM8 / kalker

Scientific calculator with math syntax that supports user-defined variables and functions, complex numbers, and estimation of derivatives and integrals
https://kalker.xyz
MIT License
1.59k stars 70 forks source link

Resquest: Auto-insert 'ans' #70

Open bokeron2020 opened 2 years ago

bokeron2020 commented 2 years ago

Hi!

Since I chose Kalker as my pc calculator I am noticing a few things I misss or would like Kalker to do.

One of those things is ability to continue an operation based on previous result. Yes, that's what ans is for. I use 'ans' when the calculation involving the previous result is complex or ans is not the first item in the command line.

What I miss is the ability to input expressions like '+2' and be interpreted as 'ans+2', or in other words I would like that a command line that starts with an operator was autocompleted with 'ans' before the operator.

BTW, 'ans' defaults to 1. That was not expected, I supposed it would default to 0. For this 'ans autocompletion' I'm talking about maybe it should default to 0.

PaddiM8 commented 2 years ago

This would be very convenient! However, wouldn't it get confusing when it comes to subtraction? A minus sign at the start could just be a negative number.

>> 1+2
2
>> +3
5
>> -2
-2 or 3?
bokeron2020 commented 2 years ago

Hmm... off the top of my head I see 3 ways to handle it only at the beginning of an empty command line:

I guess I prefer the first option but I don't know what would fit better in your development plans (if you intend to continue developing this, of course).

The calculators I've had in my life used what was suitable for them. Simpler calculators didn't have the 'ans' or 'negative' functionality to deal with so they assumed you wanted this. I've also had a bunch of more advanced ones ... I remember one of them had two minus buttons, one for operation, one for negative sign. Doing that in pc would be messy. I don't remember how the rest of them managed this.

When I'm doing basic operations I stay at the numpad section of the keyboard, which is faster. Having to write 'ans' kinda get me out of rythm, so to speak.

PaddiM8 commented 2 years ago

Hmm these options seem a bit unintuitive, but I do agree that this would be very convenient. Good point with the numpad as well, it would be good find a solution that is compatible with this. Hmm I'll think about it.