From 242a26e0db35d249a494ce3ed1db46e8c4771db6 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Thu, 24 Oct 2019 21:25:06 +0200 Subject: [PATCH] core: last_pair: Prepare for M2-Planet. * src/lib.c (last_pair): Prepare for M2-Planet. --- src/lib.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib.c b/src/lib.c index 9ab8b98d..b5450b25 100644 --- a/src/lib.c +++ b/src/lib.c @@ -198,8 +198,12 @@ equal2: SCM last_pair (SCM x) { - while (x != cell_nil && CDR (x) != cell_nil) - x = CDR (x); + while (x != cell_nil) + { + if (CDR (x) == cell_nil) + return x; + x = CDR (x); + } return x; }