1
0
Fork 0

Some fixes

This commit is contained in:
Alex Kotov 2023-05-06 02:42:34 +04:00
parent 0aac6f18b2
commit f55386304b
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
2 changed files with 9 additions and 6 deletions

View file

@ -515,22 +515,21 @@ struct Object *func_newline(
void display_pair(struct Object *const pair)
{
assert(pair);
assert(pair->type == TYPE_PAIR);
assert(Object_is_pair(pair));
struct Object *pair1[2] = { Object_new_pair(pair->pair.car, NULL), NULL };
struct Object *pair1[2] = { pair->pair.car, NULL };
func_display(1, pair1);
if (!pair->pair.cdr) return;
printf(" ");
if (pair->pair.cdr->type == TYPE_PAIR) {
if (Object_is_pair(pair->pair.cdr)) {
display_pair(pair->pair.cdr);
return;
}
printf(". ");
struct Object *pair2[2] = { Object_new_pair(pair->pair.cdr, NULL), NULL };
struct Object *pair2[2] = { pair->pair.cdr, NULL };
func_display(1, pair2);
}

View file

@ -45,7 +45,11 @@ int main()
struct Object *const result = eval(program);
printf("=> ");
eval(Object_build_list(2, Object_new_symbol("displayln"), result));
eval(Object_build_list(
2,
Object_new_symbol("displayln"),
Object_build_list(2, Object_new_symbol("quote"), result)
));
}
exit(EXIT_SUCCESS);