From b28b911ac31481fe4bb3aa3e4a1e73cf15703d04 Mon Sep 17 00:00:00 2001 From: kappa Date: Thu, 17 Jan 2019 09:38:09 +0100 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=BC=D0=B5=D1=9A=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BE=D0=BF=D1=88=D1=82=D0=B0=20=D0=BD=D0=BE?= =?UTF-8?q?=D1=82=D0=B0=D1=86=D0=B8=D1=98=D0=B5=20=D0=BB=D0=B8=D1=81=D1=82?= =?UTF-8?q?=D0=B5=20=D1=83=20=D0=BF=D1=80=D0=B8=D0=BD=D1=82=20=D1=84=D1=83?= =?UTF-8?q?=D0=BD=D0=BA=D1=86=D0=B8=D1=98=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- print.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/print.c b/print.c index 0b66d2d..9a0fed3 100644 --- a/print.c +++ b/print.c @@ -45,9 +45,21 @@ void printValue(object input) else if (input.type == consObject) { printf("("); - printValue(CAR(input)); - printf(" . "); - printValue(CDR(input)); + object *currentCell = &input; + while (TYPE(*currentCell) == consObject) + { + printValue(CAR(*currentCell)); + if (TYPE(CDR(*currentCell)) == consObject) + { + printf(" "); + } + currentCell = &CDR(*currentCell); + } + if (TYPE(*currentCell) != nilObject) + { + printf(" . "); + printValue(*currentCell); + } printf(")"); } }