2023-05-08 07:48:56 -04:00
|
|
|
(define (first x) (car x))
|
|
|
|
(define (second x) (cadr x))
|
|
|
|
(define (third x) (caddr x))
|
|
|
|
|
|
|
|
(define (last x)
|
|
|
|
(if (null? (cdr x))
|
|
|
|
(car x)
|
|
|
|
(last (cdr x))))
|
|
|
|
|
2023-05-05 17:37:04 -04:00
|
|
|
(define (caar x) (car (car x)))
|
|
|
|
(define (cadr x) (car (cdr x)))
|
|
|
|
(define (cdar x) (cdr (car x)))
|
|
|
|
(define (cddr x) (cdr (cdr x)))
|
|
|
|
|
|
|
|
(define (caaar x) (car (car (car x))))
|
|
|
|
(define (caadr x) (car (car (cdr x))))
|
|
|
|
(define (cadar x) (car (cdr (car x))))
|
|
|
|
(define (caddr x) (car (cdr (cdr x))))
|
|
|
|
(define (cdaar x) (cdr (car (car x))))
|
|
|
|
(define (cdadr x) (cdr (car (cdr x))))
|
|
|
|
(define (cddar x) (cdr (cdr (car x))))
|
|
|
|
(define (cdddr x) (cdr (cdr (cdr x))))
|
|
|
|
|
|
|
|
(define (caaaar x) (car (car (car (car x)))))
|
|
|
|
(define (caaadr x) (car (car (car (cdr x)))))
|
|
|
|
(define (caadar x) (car (car (cdr (car x)))))
|
|
|
|
(define (caaddr x) (car (car (cdr (cdr x)))))
|
|
|
|
(define (cadaar x) (car (cdr (car (car x)))))
|
|
|
|
(define (cadadr x) (car (cdr (car (cdr x)))))
|
|
|
|
(define (caddar x) (car (cdr (cdr (car x)))))
|
|
|
|
(define (cadddr x) (car (cdr (cdr (cdr x)))))
|
|
|
|
(define (cdaaar x) (cdr (car (car (car x)))))
|
|
|
|
(define (cdaadr x) (cdr (car (car (cdr x)))))
|
|
|
|
(define (cdadar x) (cdr (car (cdr (car x)))))
|
|
|
|
(define (cdaddr x) (cdr (car (cdr (cdr x)))))
|
|
|
|
(define (cddaar x) (cdr (cdr (car (car x)))))
|
|
|
|
(define (cddadr x) (cdr (cdr (car (cdr x)))))
|
|
|
|
(define (cdddar x) (cdr (cdr (cdr (car x)))))
|
|
|
|
(define (cddddr x) (cdr (cdr (cdr (cdr x)))))
|
2023-05-05 17:40:16 -04:00
|
|
|
|
|
|
|
(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)))
|