prettier printing

This commit is contained in:
Peter McGoron 2024-06-23 00:44:54 -04:00
parent 41f05b9556
commit 38b044921f
1 changed files with 16 additions and 15 deletions

17
main.c
View File

@ -764,24 +764,25 @@ static void display(struct uns_ctr *ctr)
tmp.p = gc.record_get_ptr(ctr->p, 1);
display(&tmp);
tmp.p = gc.record_get_ptr(ctr->p, 2);
switch (get_type(tmp.p)) {
case EMPTY_LIST:
printf(")");
goto remove;
case CELL:
ctr->p = gc.record_get_ptr(ctr->p, 2);
while (get_type(ctr->p) == CELL) {
printf(" ");
tmp.p = gc.record_get_ptr(ctr->p, 1);
display(&tmp);
ctr->p = gc.record_get_ptr(ctr->p, 2);
}
switch (get_type(ctr->p)) {
case EMPTY_LIST:
printf(")");
break;
default:
printf(" . ");
display(&tmp);
display(ctr);
printf(")");
break;
}
remove:
uns_root_remove(&gc, &tmp);
return;
case INTEGER: