User functions

Issue #38 closed
Former user created an issue

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)

  1. Former user Account Deleted

    ``` 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

  2. Former user Account Deleted

    Reported by `helder.pereira.correia` on 2007-06-12 09:52:16 - Labels added: Milestone-Release1.0

  3. Former user Account Deleted

    ``` I second that... I miss that feature a lot... ```

    Reported by `nunopiment` on 2007-08-05 14:18:19

  4. Former user 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

  5. Former user Account Deleted

    Reported by `helder.pereira.correia` on 2007-12-16 21:46:31 - Status changed: `New` - Labels removed: Milestone-Release1.0

  6. Former user 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

  7. Former user 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

  8. Former user 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

  9. Former user 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

  10. Former user 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

  11. Former user 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

  12. Former user 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`

  13. Former user 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

  14. Former user 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

  15. Former user 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

  16. Former user 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

  17. Former user 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

  18. Former user Account Deleted
    Added forgotten sources in revision 0dba3d4.
    

    Reported by helder.pereira.correia on 2014-06-11 01:20:31

  19. Log in to comment