diff options
Diffstat (limited to 'net/ricketyspace')
-rw-r--r-- | net/ricketyspace/sicp/two/twentynine.scm | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/net/ricketyspace/sicp/two/twentynine.scm b/net/ricketyspace/sicp/two/twentynine.scm index cc1380c..8e1aaa2 100644 --- a/net/ricketyspace/sicp/two/twentynine.scm +++ b/net/ricketyspace/sicp/two/twentynine.scm @@ -27,12 +27,13 @@ (define (branch-structure branch) (car (cdr branch))) +(define (branch-weight b) + (let ((bs (branch-structure b))) + (cond ((not (pair? bs)) bs) + (else (+ (branch-weight (left-branch bs)) + (branch-weight (right-branch bs))))))) + (define (total-weight mobile) - (define (branch-weight b) - (let ((bs (branch-structure b))) - (cond ((not (pair? bs)) bs) - (else (+ (branch-weight (left-branch bs)) - (branch-weight (right-branch bs))))))) (+ (branch-weight (left-branch mobile)) (branch-weight (right-branch mobile)))) |