Beispiel #1
0
lval *builtin(lval *v, char *func) {
    if (strcmp("head", func) == 0) {
        return builtin_head(v);
    }
    if (strcmp("tail", func) == 0) {
        return builtin_tail(v);
    }
    if (strcmp("init", func) == 0) {
        return builtin_init(v);
    }
    if (strcmp("join", func) == 0) {
        return builtin_join(v);
    }
    if (strcmp("eval", func) == 0) {
        return builtin_eval(v);
    }
    if (strcmp("list", func) == 0) {
        return builtin_list(v);
    }
    if (strcmp("cons", func) == 0) {
        return builtin_cons(v);
    }
    if (strcmp("len", func) == 0) {
        return builtin_len(v);
    }

    return builtin_op(v, func);
}
static lval * builtin(lval *a, char *func) {
	if (strcmp("list", func) == 0) { return builtin_list(a); }
	if (strcmp("head", func) == 0) { return builtin_head(a); }
	if (strcmp("tail", func) == 0) { return builtin_tail(a); }
	if (strcmp("join", func) == 0) { return builtin_join(a); }
	if (strcmp("eval", func) == 0) { return builtin_eval(a); }
	if (strcmp("cons", func) == 0) { return builtin_cons(a); }
	if (strcmp("len",  func) == 0) { return builtin_len(a); }
	if (strstr("+-/*%^", func)) { return builtin_op(a, func); }
	lval_del(a);
	return lval_err("Unknown Function!");
}