From 09096bfaa15c34ba4c6010cc0765658e6327c19f Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 24 Mar 2018 05:54:29 +0000 Subject: net: Add (net ricketyspace sicp one fortythree) --- net/ricketyspace/sicp/one/fortythree.scm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 net/ricketyspace/sicp/one/fortythree.scm (limited to 'net/ricketyspace') diff --git a/net/ricketyspace/sicp/one/fortythree.scm b/net/ricketyspace/sicp/one/fortythree.scm new file mode 100644 index 0000000..f84d17b --- /dev/null +++ b/net/ricketyspace/sicp/one/fortythree.scm @@ -0,0 +1,24 @@ +;;;; Under Creative Commons Attribution-ShareAlike 4.0 +;;;; International. See +;;;; . +;;;; + +(define-module (net ricketyspace sicp one fortythree) + #:use-module (net ricketyspace sicp one fortytwo) + #:export (repeated square)) + +(define (repeated f n) + (cond ((= n 1) (lambda (x) (f x))) + (else (sicp-compose f (repeated f (1- n)))))) + +(define (square x) (* x x)) + +;;; GNU Guile REPL +;;; +;;; scheme@(guile-user)> ,re (net ricketyspace sicp one fortythree) +;;; scheme@(guile-user)> ((repeated square 1) 5) +;;; $7 = 25 +;;; scheme@(guile-user)> ((repeated square 2) 5) +;;; $8 = 625 +;;; scheme@(guile-user)> ((repeated square 3) 5) +;;; $9 = 390625 -- cgit v1.2.3