1
0
Fork 0

funcs "list-tail", "list-ref"

This commit is contained in:
Alex Kotov 2023-05-06 01:40:16 +04:00
parent 8482bd2dae
commit 9eca3ac0b9
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08

View file

@ -28,3 +28,10 @@
(define (cddadr x) (cdr (cdr (car (cdr x)))))
(define (cdddar x) (cdr (cdr (cdr (car x)))))
(define (cddddr x) (cdr (cdr (cdr (cdr x)))))
(define (list-tail x k)
(if (zero? k)
x
(list-tail (cdr x) (- k 1))))
(define (list-ref x k) (car (list-tail x k)))