core: last_pair: Move to core.

* src/lib.c (last_pair): New function.
* module/mes/scm.mes (last-pair): Remove.
This commit is contained in:
Jan Nieuwenhuizen 2018-04-24 07:00:35 +02:00
parent 4fa6acc480
commit 18d143aa62
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
2 changed files with 8 additions and 5 deletions

View file

@ -157,11 +157,6 @@
(if (= 0 n) x
(list-tail (cdr x) (- n 1))))
(define (last-pair lst)
(let loop ((lst lst))
(if (or (null? lst) (null? (cdr lst))) lst
(loop (cdr lst)))))
(define (iota n)
(if (<= n 0) '()
(append2 (iota (- n 1)) (list (- n 1)))))

View file

@ -331,3 +331,11 @@ equal2_p (SCM a, SCM b)
}
return eq_p (a, b);
}
SCM
last_pair (SCM x)
{
while (x != cell_nil && CDR (x) != cell_nil)
x = CDR (x);
return x;
}