test
[calc.git] / argument.c
CommitLineData
33b4877a
LM
1#include <stdio.h>
2
c91672f9
LM
3#include "parser.h"
4#include "tabular.h"
5
6#include "argument.h"
7
8/* global variables */
9
10tab_t *argument = NULL;
11
12/* argument management */
13
14/* get argument */
15
16double arg (int n)
17{
18 return get_tab (argument, n);
19}
20
21/* set arguments */
22
23double def (int nbops, element_t **ops)
24{
25 int i;
33b4877a 26 tab_t *new = alloc_tab (nbops);
c91672f9 27 for (i = 0; i < nbops; i++) {
33b4877a
LM
28 double val = evaluate_element (ops[i], 0);
29 VERBOSE (DEBUG, fprintf (stdout, "arg[%d] = %g\n", i + i, val));
30 set_tab (new, i + 1, val);
c91672f9 31 }
33b4877a
LM
32 free_tab (argument);
33 argument = new;
c91672f9
LM
34 return size_tab (argument);
35}
36
37/* vim: set ts=4 sw=4 et: */