static pSlipObject expand_clauses(pSlip gd, pSlipObject clauses) { pSlipObject first; pSlipObject rest; if (sIsObject_EmptyList(gd, clauses) == S_TRUE) { return gd->singleton_False; } else { first = car(clauses); rest = cdr(clauses); if (is_cond_else_clause(gd, first) == S_TRUE) { if (sIsObject_EmptyList(gd, rest) == S_TRUE) { return sequence_to_exp(gd, cond_actions(first)); } else { throw_error(gd, "else clause isn't last cond->if"); return gd->singleton_False; } } else { return make_if(gd, cond_predicate(first), sequence_to_exp(gd, cond_actions(first)), expand_clauses(gd, rest)); } } }
object *expand_clauses(object *clauses) { object *first; object *rest; if (is_the_empty_list(clauses)) { return false; } else { first = car(clauses); rest = cdr(clauses); if (is_cond_else_clause(first)) { if (is_the_empty_list(rest)) { return sequence_to_exp(cond_actions(first)); } else { fprintf(stderr, "else clause isn't last cond->if"); exit(1); } } else { return make_if(cond_predicate(first), sequence_to_exp(cond_actions(first)), expand_clauses(rest)); } } }
object *expand_clauses(object *clauses) { object *first; object *rest; if (is_empty(clauses)) return false; first = car(clauses); rest = cdr(clauses); if (!is_cond_else_clause(first)) return make_if(cond_predicate(first), sequence_to_exp(cond_actions(first)), expand_clauses(rest)); if (is_empty(rest)) return sequence_to_exp(cond_actions(first)); fprintf(stderr, "else clause isn't last cond->if"); exit(EXIT_FAILURE); }
static data_t *expand_clauses(const data_t *clauses) { data_t *first, *rest; if(clauses == NULL) return make_symbol("#f"); first = car(clauses); rest = cdr(clauses); if(is_cond_else_clause(first)) { if(rest == NULL) { return sequence_to_exp(get_cond_actions(first)); } else { printf("ELSE clause isn't last -- COND-IF"); return make_symbol("error"); } } return make_if(get_cond_predicate(first), sequence_to_exp(get_cond_actions(first)), expand_clauses(rest)); }
static object *expand_clauses(object *clauses) { if (is_empty_list(clauses)) { return get_boolean(0); } else { object *first = car(clauses); object *rest = cdr(clauses); if (cond_predicate(first) == lookup_symbol("else")) { if (is_empty_list(rest)) { return sequence_to_exp(cond_actions(first)); } else { error("else clause must be last in cond expression"); } } else { return make_if(cond_predicate(first), sequence_to_exp(cond_actions(first)), expand_clauses(rest)); } } }