sicp

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

commit 28793f1fec7cf8d371286e87276f714f77422eda
parent c56eecd98a88ca6e1f7f625191f6164847b24829
Author: rsiddharth <s@ricketyspace.net>
Date:   Sat, 28 Jul 2018 17:31:03 +0000

Add (net ricketyspace sicp two seven).

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

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

diff --git a/net/ricketyspace/sicp/two/seven.scm b/net/ricketyspace/sicp/two/seven.scm @@ -0,0 +1,18 @@ +;;;; Under Creative Commons Attribution-ShareAlike 4.0 +;;;; International. See +;;;; <https://creativecommons.org/licenses/by-sa/4.0/>. + +(define-module (net ricketyspace sicp two seven) + #:export (make-interval + lower-bound + upper-bound + add-interval)) + +(define (make-interval a b) (cons a b)) + +(define (lower-bound x) (car x)) +(define (upper-bound x) (cdr x)) + +(define (add-interval x y) + (make-interval (+ (lower-bound x) (lower-bound y)) + (+ (upper-bound x) (upper-bound y))))