{ "|", Or, 2, 1, -2}
};
-#define NB_FUNCTIONS 14
+#define NB_FUNCTIONS 16
keyword_t functions[NB_FUNCTIONS] = {
{ "sqrt", Sqr, 1, 4, 5},
{ "pow", Pow, 2, 3, 5},
{ "log", Log, 1, 3, 5},
{ "sto", Store, 2, 3, 9},
{ "rcl", Recall, 1, 3, 5},
+ { "inc", Inc, 1, 3, 5},
+ { "dec", Dec, 1, 3, 5},
{ "disp", Disp, 0, 4, 9},
{ "quit", Quit, 0, 4, 9},
{ "help", Help, 0, 4, 9},
case Exp: func = "Exponantial"; break;
case Store: func = "Store"; break;
case Recall: func = "Recall"; break;
+ case Inc: func = "Increase"; break;
+ case Dec: func = "Decrease"; break;
case Disp: func = "Display"; break;
case Quit: func = "Quit"; break;
case Help: func = "Help"; break;
return 0;
}
+double increase (int index)
+{
+ if ((index > 0) && (index <= STORAGE_SIZE)) {
+ return storage[index - 1]++;
+ } else {
+ VERBOSE (WARNING, fprintf (stdout, "invalid index (%d) [1, %d]\n", index, STORAGE_SIZE));
+ }
+ return 0;
+}
+
+double decrease (int index)
+{
+ if ((index > 0) && (index <= STORAGE_SIZE)) {
+ return storage[index - 1]--;
+ } else {
+ VERBOSE (WARNING, fprintf (stdout, "invalid index (%d) [1, %d]\n", index, STORAGE_SIZE));
+ }
+ return 0;
+}
+
void display (void)
{
int i;
fprintf (stdout, "supported functions:");
fprintf (stdout, " pow sqrt cos sin atan log exp\n");
fprintf (stdout, "storage functions:");
- fprintf (stdout, " sto rcl\n");
+ fprintf (stdout, " sto rcl inc dec\n");
fprintf (stdout, "conditional functions:");
fprintf (stdout, " cond\n");
fprintf (stdout, "miscellaneous functions:");
case Log:
case Exp:
case Recall:
+ case Inc:
+ case Dec:
case Not:
case Cond:
if (root->ops[0]) {
case Exp: return exp (op0);
case Store: return store ((int)op0, (op1) ? op1 : answer);
case Recall: return recall ((int)op0);
+ case Inc: return increase ((int)op0);
+ case Dec: return decrease ((int)op0);
case Disp: display (); break;
case Quit: quit (); break;
case Help: help (); break;