From 19ed602c1ba7dc2b933274f50085c9c4f0f1105c Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 14 Jan 2017 21:44:28 +0000 Subject: one -> net/ricketyspace/sicp --- one/fourteen.scm | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 one/fourteen.scm (limited to 'one/fourteen.scm') diff --git a/one/fourteen.scm b/one/fourteen.scm deleted file mode 100644 index 4186238..0000000 --- a/one/fourteen.scm +++ /dev/null @@ -1,43 +0,0 @@ -;;;; Under Creative Commons Attribution-ShareAlike 4.0 -;;;; International. See -;;;; . - -;;; adapted from section 1.2.2 -;;; intolerable scheme drivel; ignore it. - -(define-module (one fourteen) - #:export (get-cc - cc-range - cc-diff-list)) - -(define (get-cc) - (let ((no-of-steps 0)) - (define (cc amount kinds-of-coins) - (set! no-of-steps (1+ no-of-steps)) - (cond ((= amount 0) 1) - ((or (< amount 0) (= kinds-of-coins 0)) 0) - (else (+ (cc amount - (- kinds-of-coins 1)) - (cc (- amount - (first-denomination kinds-of-coins)) - kinds-of-coins))))) - (define (first-denomination kinds-of-coins) - (cond ((= kinds-of-coins 1) 1) - ((= kinds-of-coins 2) 5) - ((= kinds-of-coins 3) 10) - ((= kinds-of-coins 4) 25) - ((= kinds-of-coins 5) 50))) - (lambda (amount) - (cc amount 5) - no-of-steps))) - -(define (cc-range amount limit incr) - (cond ((> amount limit) '()) - ((<= amount limit) - (cons ((get-cc) amount) - (cc-range (+ amount incr) limit incr))))) - -(define (cc-diff-list l) - (cond ((= (length l) 1) '()) - ((> (length l) 1) (cons (+ (* -1 (car l)) (cadr l)) - (cc-diff-list (cdr l)))))) -- cgit v1.2.3