HoubySoft.com   up since 27.11.2007
USER-DEFINED VARIABLES AND FUNCTIONS ==================================== From hc version 0.5, there is support for user-defined variables and functions in the calculator. From hc version 0.9.4, there is also support for file-loading with the \load command. This is a brief description of how to use them and how they work. Naming ------ Names must consist of only numbers and letters. The first character must be a letter. Defining -------- To define a variable, use this syntax: VAR_NAME = VAR_VALUE VAR_NAME is the variable's name (surprisingly), and VAR_VALUE is any valid expression. So, for example, to define a new variable named x and having the value 27, you would type for example this: x = 20+7+sqrt(0) Then, you can use x in calculations, so after this definition, if you type x^2, you will get this answer: > x^2 729 To define a function, use this syntax: FUNC_NAME(ARG1, ARG2, ..., ARGN) = EXPRESSION FUNC_NAME is again the function's name, ARG1...N are its arguments, and EXPRESSION is the function's expression. I'll give you an example again since I think this is the best way to demonstrate how to use this. Let's say you want to create a function that will square its first argument, and you want to name it func. To accomplish that, you would type (for example): func(x) = x^2 Then you can test your new function by typing for example func(3) in the prompt; you will get 9 as the answer. Clearing -------- If you want to clear all custom variables and functions that you defined, either restart the program, or type \clear in the command line version. Please also keep in mind that you can always redefine a variable that you defined, so if you made for example a squaring function: > func(x) = x^2 but then you want it to be a cubeing function, just type: > func(x) = x^3 Loading files ------------ From hc version 0.9.4, it is also possible to "load in" a file with any valid hc expressions, including variable and function definitions. The syntax of the command is: \load FILE Note: In the GUI, use the File > Load/Open command. where FILE is a text file on your system which contains the commands, one per line. So for example, to load a file named defs.txt, simply type: \load defs.txt This feature can be used for example to load in functions that you use often.
My git hub account