In exercise 2.17, there is an error with the test on hexlets site, which should be reported to them.
10 lines
341 B
Scheme
10 lines
341 B
Scheme
#lang sicp
|
|
|
|
(define (same-parity fst . lst)
|
|
(define (same-parity-aux parity lst)
|
|
(cond ((null? lst) '())
|
|
((equal? parity (even? (car lst)))
|
|
(cons (car lst) (same-parity-aux parity (cdr lst))))
|
|
(else (same-parity-aux parity (cdr lst)))))
|
|
(same-parity-aux (even? fst)
|
|
(cons fst lst)))
|