summaryrefslogtreecommitdiffstats
path: root/net/ricketyspace
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2018-12-08 12:04:50 -0500
committerrsiddharth <s@ricketyspace.net>2018-12-08 12:04:50 -0500
commit50b48911bdff2ee90c203b22baf3953d2b23b24a (patch)
treec2422dacd3cdb9249222ce6cbe1f0b61faedb1bf /net/ricketyspace
parentfc933303d5b5c15e3f912f74dc1af6c1ba3118c5 (diff)
Add (net ricketyspace sicp two twenty).
Diffstat (limited to 'net/ricketyspace')
-rw-r--r--net/ricketyspace/sicp/two/twenty.scm14
1 files changed, 14 insertions, 0 deletions
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)))