sicp-solutions/ex-2.17.scm
Petar Kapriš da96368e0b Add solutions to exercises from subsection 2.2.1
In exercise 2.17, there is an error with the test on hexlets site, which
should be reported to them.
2025-02-06 11:08:54 +01:00

7 lines
182 B
Scheme

#lang sicp
(define (last-pair list)
(cond ((null? list) (error "Can't get last element of empty list"))
((null? (cdr list)) list)
(else (last-pair (cdr list)))))