Skip to content

Commit 5e7d72c

Browse files
authored
Update README.md
1 parent ae67a0d commit 5e7d72c

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,31 @@ input and returns floating-point number as a result.
2222
#include "expr.h"
2323

2424
// Custom function that returns the sum of its two arguments
25-
static float add(struct expr_func *f, vec_expr_t args, void *c) {
26-
float a = expr_eval(&vec_nth(&args, 0));
27-
float b = expr_eval(&vec_nth(&args, 1));
25+
static float add(struct expr_func *f, vec_expr_t *args, void *c) {
26+
float a = expr_eval(&vec_nth(args, 0));
27+
float b = expr_eval(&vec_nth(args, 1));
2828
return a + b;
2929
}
3030

31-
static struct expr_func funcs[] = {
32-
{"add", add, 0},
33-
{NULL, NULL, 0},
31+
static struct expr_func user_funcs[] = {
32+
{"add", add, NULL, 0},
33+
{NULL, NULL, NULL, 0},
3434
};
3535

3636
int main() {
37-
const char *s = "x = 5, add(2, x)";
37+
const char *s = "x = 5, add(2, x)";
3838
struct expr_var_list vars = {0};
3939
struct expr *e = expr_create(s, strlen(s), &vars, user_funcs);
4040
if (e == NULL) {
4141
printf("Syntax error");
42-
return 1;
43-
}
42+
return 1;
43+
}
4444

45-
float result = expr_eval(e);
46-
printf("result: %f\n", result);
45+
float result = expr_eval(e);
46+
printf("result: %f\n", result);
4747

48-
expr_destroy(e, &vars);
49-
return 0;
48+
expr_destroy(e, &vars);
49+
return 0;
5050
}
5151
```
5252

0 commit comments

Comments
 (0)