summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2018-12-22 21:30:26 -0500
committerrsiddharth <s@ricketyspace.net>2018-12-22 21:30:26 -0500
commit4bb59df548b0e722556430393936abaa52849795 (patch)
treeef709516f0246e266bd85d4b060938f4add6f856
parent50b48911bdff2ee90c203b22baf3953d2b23b24a (diff)
Add (net ricketyspace sicp two twentyone).
-rw-r--r--net/ricketyspace/sicp/two/twentyone.scm14
1 files changed, 14 insertions, 0 deletions
diff --git a/net/ricketyspace/sicp/two/twentyone.scm b/net/ricketyspace/sicp/two/twentyone.scm
new file mode 100644
index 0000000..8ad559e
--- /dev/null
+++ b/net/ricketyspace/sicp/two/twentyone.scm
@@ -0,0 +1,14 @@
+;;;; License: CC0-1.0
+
+(define-module (net ricketyspace sicp two twentyone)
+ #:export (square-list-v1
+ square-list-v2))
+
+(define (square-list-v1 items)
+ (if (null? items)
+ items
+ (cons (* (car items) (car items))
+ (square-list-v1 (cdr items)))))
+
+(define (square-list-v2 items)
+ (map (lambda (x) (* x x)) items))