From 50b48911bdff2ee90c203b22baf3953d2b23b24a Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 8 Dec 2018 12:04:50 -0500 Subject: Add (net ricketyspace sicp two twenty). --- net/ricketyspace/sicp/two/twenty.scm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 net/ricketyspace/sicp/two/twenty.scm diff --git a/net/ricketyspace/sicp/two/twenty.scm b/net/ricketyspace/sicp/two/twenty.scm new file mode 100644 index 0000000..a48704a --- /dev/null +++ b/net/ricketyspace/sicp/two/twenty.scm @@ -0,0 +1,14 @@ +;;;; License: CC0-1.0 + +(define-module (net ricketyspace sicp two twenty) + #:export (same-parity)) + +(define (same-parity x . y) + (define x-parity (remainder x 2)) + (define (find nums) + (cond ((null? nums) '()) + ((= x-parity (remainder (car nums) 2)) + (cons (car nums) (find (cdr nums)))) + (else + (find (cdr nums))))) + (cons x (find y))) -- cgit v1.2.3