From 95b2ccf229800dc12a8cb9830fc8986509211ff6 Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan <vu3rdd@gmail.com> Date: Fri, 26 Nov 2010 18:08:07 +0530 Subject: [PATCH] solution to 2.61 and 2.62 --- src/sicp/ex2_61.rkt | 7 +++++++ src/sicp/ex2_62.rkt | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 src/sicp/ex2_61.rkt create mode 100644 src/sicp/ex2_62.rkt diff --git a/src/sicp/ex2_61.rkt b/src/sicp/ex2_61.rkt new file mode 100644 index 0000000..a443206 --- /dev/null +++ b/src/sicp/ex2_61.rkt @@ -0,0 +1,7 @@ +#lang racket + +(define (adjoin-set x set) + (cond ((null? set) (cons x set)) + ((= x (car set)) set) + ((< x (car set)) (cons x set)) + ((> x (car set)) (cons (car set) (adjoin-set x (cdr set)))))) \ No newline at end of file diff --git a/src/sicp/ex2_62.rkt b/src/sicp/ex2_62.rkt new file mode 100644 index 0000000..47fb870 --- /dev/null +++ b/src/sicp/ex2_62.rkt @@ -0,0 +1,8 @@ +#lang racket + +(define (union-set set1 set2) + (cond ((null? set1) set2) + ((null? set2) set1) + ((= (car set1) (car set2)) (cons (car set1) (union-set (cdr set1) (cdr set2)))) + ((< (car set1) (car set2)) (cons (car set1) (union-set (cdr set1) set2))) + ((> (car set1) (car set2)) (cons (car set2) (union-set set1 (cdr set2)))))) \ No newline at end of file -- 2.45.2