sicp

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

commit cf005bd0c4b79167e2d97e6a51fc95fbb6fa820f
parent d548d2a4d08896dfd8d55e9909cebcb744234947
Author: rsiddharth <s@ricketyspace.net>
Date:   Sun, 30 Jun 2019 12:45:21 -0400

Add (net ricketyspace sicp two twentyeight).

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

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

diff --git a/net/ricketyspace/sicp/two/twentyeight.scm b/net/ricketyspace/sicp/two/twentyeight.scm @@ -0,0 +1,21 @@ +;;;; License: CC0-1.0 + +(define-module (net ricketyspace sicp two twentyeight) + #:export (fringe)) + +(define (fringe x) + (cond ((null? x) '()) + ((not (pair? x)) (list x)) + (else (append (fringe (car x)) + (fringe (cdr x)))))) + + +;;; Guile REPL + +;;; scheme@(guile-user)> ,use (net ricketyspace sicp two twentyeight) +;;; scheme@(guile-user)> (define x (list (list 1 2) (list 3 4))) +;;; +;;; scheme@(guile-user)> (fringe x) +;;; $12 = (1 2 3 4) +;;; scheme@(guile-user)> (fringe (list x x)) +;;; $13 = (1 2 3 4 1 2 3 4)