fix bracket evaluation
[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
89a2c19d 23tab_t *def (int nbops, element_t **ops)
c91672f9
LM
24{
25 int i;
33b4877a 26 tab_t *new = alloc_tab (nbops);
c91672f9 27 for (i = 0; i < nbops; i++) {
33b4877a 28 double val = evaluate_element (ops[i], 0);
2ddb38f0 29 VERBOSE (DEBUG, fprintf (stdout, "value %d/%d = %g\n", i + 1, nbops, val));
33b4877a 30 set_tab (new, i + 1, val);
c91672f9 31 }
89a2c19d 32 return new;
c91672f9
LM
33}
34
35/* vim: set ts=4 sw=4 et: */