ScmObj Scm_ArrayToListWithTail(ScmObj *elts, int nelts, ScmObj tail) { ScmObj h = SCM_NIL, t = SCM_NIL; if (elts) { for (int i=0; i<nelts; i++) SCM_APPEND1(h, t, *elts++); } if (!SCM_NULLP(tail)) SCM_APPEND(h, t, tail); return h; }
ScmObj Scm_MakeCompoundCondition(ScmObj conditions) { ScmObj h = SCM_NIL, t = SCM_NIL; int serious = FALSE; int nconds = Scm_Length(conditions); /* some boundary cases */ if (nconds < 0) { Scm_Error("Scm_MakeCompoundCondition: list required, but got %S", conditions); } if (nconds == 0) { return compound_allocate(SCM_CLASS_COMPOUND_CONDITION, SCM_NIL); } if (nconds == 1) { if (!SCM_CONDITIONP(SCM_CAR(conditions))) { Scm_Error("make-compound-condition: given non-condition object: %S", SCM_CAR(conditions)); } return SCM_CAR(conditions); } /* collect conditions and creates compound one */ ScmObj cp; SCM_FOR_EACH(cp, conditions) { ScmObj c = SCM_CAR(cp); if (!SCM_CONDITIONP(c)) { Scm_Error("make-compound-condition: given non-condition object: %S", SCM_CAR(cp)); } if (SCM_SERIOUS_CONDITION_P(c)) { serious = TRUE; } if (SCM_COMPOUND_CONDITION_P(c)) { ScmCompoundCondition *cc = SCM_COMPOUND_CONDITION(c); SCM_APPEND(h, t, cc->conditions); } else { SCM_APPEND1(h, t, c); } }
ScmObj Scm_DeleteKeyword(ScmObj key, ScmObj list) { ScmObj cp; SCM_FOR_EACH(cp, list) { if (!SCM_PAIRP(SCM_CDR(cp))) { Scm_Error("incomplete key list: %S", list); } if (key == SCM_CAR(cp)) { /* found */ ScmObj h = SCM_NIL, t = SCM_NIL; ScmObj tail = Scm_DeleteKeyword(key, SCM_CDR(SCM_CDR(cp))); ScmObj cp2; SCM_FOR_EACH(cp2, list) { if (cp2 == cp) { SCM_APPEND(h, t, tail); return h; } else { SCM_APPEND1(h, t, SCM_CAR(cp2)); } } } cp = SCM_CDR(cp); }