summaryrefslogtreecommitdiffstats
path: root/net/ricketyspace
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2019-12-26 21:33:42 -0500
committerrsiddharth <s@ricketyspace.net>2019-12-26 21:33:42 -0500
commit7f64b4262ee7c71c6fe2593cd00b5606a14a8155 (patch)
tree0d88699a3e9386634fd5a03c63371ba2b5d34007 /net/ricketyspace
parent19efa1a78b2c15f64a1e186f2a6eebfad7d75db2 (diff)
Add (net ricketyspace sicp two thirtynine).
* net/ricketyspace/sicp/two/thirtynine.scm: New file.
Diffstat (limited to 'net/ricketyspace')
-rw-r--r--net/ricketyspace/sicp/two/thirtynine.scm22
1 files changed, 22 insertions, 0 deletions
diff --git a/net/ricketyspace/sicp/two/thirtynine.scm b/net/ricketyspace/sicp/two/thirtynine.scm
new file mode 100644
index 0000000..8c05587
--- /dev/null
+++ b/net/ricketyspace/sicp/two/thirtynine.scm
@@ -0,0 +1,22 @@
+;;;; License: CC0-1.0
+
+(define-module (net ricketyspace sicp two thirtynine)
+ #:use-module (net ricketyspace sicp two thirtyeight)
+ #:export (reverse-fr
+ reverse-fl))
+
+(define (reverse-fr sequence)
+ (fold-right (lambda (x y) (append y (list x))) '() sequence))
+
+(define (reverse-fl sequence)
+ (fold-left (lambda (x y) (append (list y) x)) '() sequence))
+
+;;;
+;;; Guile REPL
+;;;
+;;; scheme@(guile-user)> ,re (net ricketyspace sicp two thirtynine)
+;;; scheme@(guile-user)> (reverse-fr '(1 2 3 4 5 6))
+;;; $8 = (6 5 4 3 2 1)
+;;; scheme@(guile-user)> (reverse-fl '(1 2 3 4 5 6))
+;;; $9 = (6 5 4 3 2 1)
+;;;