summaryrefslogtreecommitdiffstats
path: root/net/ricketyspace/sicp/two/twentyone.scm
diff options
context:
space:
mode:
Diffstat (limited to 'net/ricketyspace/sicp/two/twentyone.scm')
-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))