Closed cryogenicminer closed 6 years ago
I agree, those are very useful functions.
@cryogenicminer @Capaverde Thanks a lot for your input, I think I can add those functions. Given the fact that we can compose functions, what would be the minimal set of primitives we should hard code?
These, to me, are the basic functions: Sin, Cos, Tan, and Log.
Csc, Sec, and Cot can be defined in Words from standard Trig. If Log allows for different bases, then Ln can be defined in Words too. Otherwise, add Log (base 10) and Log (base e - Ln). The rest can be defined in Words like 'pi', 'e', and 'sqrt' etc.
Maybe we could work on offering a Words file for derived functions.
Anything I missed @Capaverde ? Edit: grammar & question
@cryogenicminer I just pushed the changes that include ln
, log
, sin
, cos
and tan
. You can check the documentation.
About offering a words file for derived functions: it's an excellent idea! I created a wiki page for custom words, but maybe we should make it more prominent and/or easier to install.
@cryogenicminer I think having csc, sec, cot hardcoded might make it somewhat faster than processing sin 1 swap /, cos 1 swap /, tan 1 swap /, but I'm not sure if this is too important.
The arc functions, asin, acos, atan are also useful and I find use for them on a regular basis when converting between rectangular coordinates and polar coordinates, etc.
Other than that I can think of no other function very needed currently.
Ahh, I totally spaced on arcsin etc. Yes, those are important functions, way more important than csc, sec, and cot. I think you are right @Capaverde on hardcoding, but I think it won't be used nearly as much, and providing a 'word' to do the swap should make it seamless enough.
@soveran Thank you for the additions! Played around with it a bit, works great. Midterms just took place, so time has been scarce, but I appreciate your willingness to work on features!
The new functions are available in version 0.3.2. Thanks!
I've tried making a standalone similar to this and posted a gist, calling it stack.c. Maybe you'd like to check it out, though I've ended up abandoning it. Your code was a reference, but I implemented a switch statement using word hashes, and sone other things.
Here is the code in question:
https://gist.github.com/Capaverde/7136e02f450ffbc163968348820f41a3
@Capaverde Cool implementation! Thanks a lot for sharing it!
Adding the basic functions for a scientific calculator would be great! Something along the lines of trig fn, logs. Anyways great setup for the calculator! As an engineer, these are functions I use on a regular basis.