From cf005bd0c4b79167e2d97e6a51fc95fbb6fa820f Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sun, 30 Jun 2019 12:45:21 -0400 Subject: Add (net ricketyspace sicp two twentyeight). * net/ricketyspace/sicp/two/twentyeight.scm: New file. --- net/ricketyspace/sicp/two/twentyeight.scm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 net/ricketyspace/sicp/two/twentyeight.scm diff --git a/net/ricketyspace/sicp/two/twentyeight.scm b/net/ricketyspace/sicp/two/twentyeight.scm new file mode 100644 index 0000000..dbba0e0 --- /dev/null +++ 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) -- cgit v1.2.3