User functions
Originally reported on Google Code with ID 38
It should be possible to enter the expression "func(a,b,c)=a+b+c" and have
the function "func" stored (in and between sessions). Then we enter
"func(1,2,3)" and get "6" as the result. The number of parameters should
not be limited.
Reported by helder.pereira.correia
on 2007-05-13 22:00:57
Comments (20)
-
Account Deleted -
Account Deleted Reported by `helder.pereira.correia` on 2007-06-12 09:52:16 - Labels added: Milestone-Release1.0
-
Account Deleted ``` I second that... I miss that feature a lot... ```
Reported by `nunopiment` on 2007-08-05 14:18:19
-
Account Deleted ``` The syntax used in Abakus is "set func(arglist)=expression" - it would be nice to use the same syntax. Also it would be handy to define new constants e.g. "set const=value". To remove functions/variables use unset.
I'd be against a full-blown programming script/language as I want a calculator to be small enough to load pretty-well instantaneously - if I wanw BASIC (or perl or python) I'll go into a terminal.
```
Reported by `ajp@fudokai.org.uk` on 2007-11-11 16:06:25
-
Account Deleted Reported by `helder.pereira.correia` on 2007-12-16 21:46:31 - Status changed: `New` - Labels removed: Milestone-Release1.0
-
Account Deleted ``` The best syntax for defining a function should be to just write it like a variable definition with the name followed by an argument list n parentheses, e.g.:
f(x)=x^2-3x
This format seems to be the closest to the traditional way to define a function in mathematics.
It would also be nice if you could add the ?: operator (as in C and Java), as well as the relational operators (==, !=, <, <=, >, >=) and if you allow recursive functions. Then the factorial function, for example, could be defined in something like the traditional way:
fact(n) = n == 0 ? 1 : n * fact(n-1)
This would be enough to make a very powerful and intuitive programmable desktop calculator, without the complexity of a programming language.
```
Reported by `eirik.hektoen` on 2009-03-03 08:33:22
-
Account Deleted ``` The propably most beautiful way should be the mathematical definition, e. g.:
-> f(x) := x + 1
I hope, this feature can soon be implemented. I really miss that and must often switch to a CAS instead of the more compact SpeedCrunch. ```
Reported by `raziel666raziel` on 2009-12-05 15:42:13
-
Account Deleted ``` This is the single most missed feature. As for the syntax - a simple
f(a;b)=2*a+b
would work and is simple and elegant, since we already have variable assignment:
a=3
Recursion and conditional execution operators are nice but definitely not the "must have" for initial implementation.
```
Reported by `audrius.urm` on 2009-12-28 10:12:49
-
Account Deleted ``` I vote for this as well, it would be a wonderful addition.
It seems almost superfluous to mention but all user defined functions should be remembered across sessions and be selectable from the right panel, along with the 'Math Book', 'Constants', 'Functions', etc..
The actual function notation style does not bother me but being able to edit them directly in a config text file would be most useful and would speed things up. I doubt it necessary to say but, like the variables, user defined functions should be named as the user wishes. E.G.
CompoundInterest(x;y;z) = x * ((1 + y)^z)
Being able to assign the result to a variable would also be useful. E.G.
compint = CompoundInterest(1000;0.05;5)
Thanks for the great software. ```
Reported by `jmstanfield` on 2010-05-14 21:28:25
-
Account Deleted ``` Speedcrunch is an amazing piece of software. I would love love love to be able to add my own functions though - that's something I do in the old Microsoft Powertoys calculator all the time.
It's immensely handy for the engineer who wants to have functions for resistor dividers, converting to/from decibels, etc. With the addition of functions Speedcrunch would really rock all of our socks off. ```
Reported by `nicholas.clark` on 2010-06-22 17:47:03
-
Account Deleted ``` I'm surprised that such good piece of software doesn't have custom functions. And also I'm surprised that this issue is still there after 3 years. C'mon! Whatever script langage is used, we would enjoy it. Even a simple format like "f(x)=expression..." would be enough. ```
Reported by `Gourry.Gabrief` on 2010-11-23 14:36:29
-
Account Deleted ``` @Gourry.Gabrief: Unfortunately, this piece of software does not have developers that can dedicate a considerable amount of time of their lives to it for a long time now. If you are a developer, have the knowledge, and would like to dedicate your time to this enhancement, please do so. If you know someone in these conditions please tell her. ```
Reported by `helder.pereira.correia` on 2010-11-23 19:28:25 - Status changed: `Accepted`
-
Account Deleted ``` If I may add my humble opinion:
I believe integrating scripting WITH A SMALL FOOTPRINT scripting language would bring in the most power w/o sacrificing on start-up time. Lua is such a language. (It's not necessarily my personal favorite, but good enough, and one of the lightest there is.) QtScript seems to be a sort of JavaScript, so that might work too (unsure about its footprint though).
Scripting would enable people to define their own functions, but more importantly, it would enable geeks like me to script up parsers for "function declaration mini-languages" that are simpler to use for the average user (i.e. following simpler syntaxes, like those suggested above.)
I've implemented parsers for mathematical mini-languages on various occasions, and I'd do one for me right away if there wasn't for the hassle of setting up a whole Qt/C++ dev/build environment up front. ```
Reported by `hackadelic` on 2011-10-24 06:48:55
-
Account Deleted ``` I agree with hackadelic - Lua (although I don't know it yet, and don't know if it's the most appropriate) should be integrated. ```
Reported by `muntooNXT` on 2011-10-25 03:20:57
-
Account Deleted ``` Functions are needed! You even can use QScript for this, it's quite simple. Just add text editor and QScript engine. ```
Reported by `kasatkin_serge@mail.ru` on 2012-04-23 14:08:00
-
Account Deleted I gave it a try, and it seems to work. Check that pull request please: https://github.com/speedcrunch/SpeedCrunch/pull/15 User functions are set this way: f(a;b;c) = a * b + round(c / 2.0)
Reported by
teyut@free.fr
on 2014-01-09 08:40:43 -
Account Deleted Added in revision c4a8824 thanks to Tey.
Reported by
helder.pereira.correia
on 2014-06-11 00:59:04 - Status changed:Fixed
- Labels added: Milestone-0.12 -
Account Deleted Added forgotten sources in revision 0dba3d4.
Reported by
helder.pereira.correia
on 2014-06-11 01:20:31 -
repo owner -
repo owner - changed status to closed
- Log in to comment
``` Actually, one time I was thinking about implementing a full-blown macro for this purpose. We could pick e.g. QtScript as the scripting language (it'll be with Qt 4.3). Or, if we could implemented subset of BASIC because BASIC is very easy to understand. Those who (in the past) ever owned and used programmable pocket calculator will appreciate BASIC support, I reckon. ```
Reported by `ariya.hidayat` on 2007-05-15 07:12:02