sicp

sicp sandbox.
git clone git://git.ricketyspace.net/sicp.git
Log | Files | Refs

commit 7f64b4262ee7c71c6fe2593cd00b5606a14a8155
parent 19efa1a78b2c15f64a1e186f2a6eebfad7d75db2
Author: rsiddharth <s@ricketyspace.net>
Date:   Thu, 26 Dec 2019 21:33:42 -0500

Add (net ricketyspace sicp two thirtynine).

* net/ricketyspace/sicp/two/thirtynine.scm: New file.

Diffstat:
net/ricketyspace/sicp/two/thirtynine.scm | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git a/net/ricketyspace/sicp/two/thirtynine.scm 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) +;;;