home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mitech!gjc
- From: gjc@mitech.com (George J. Carrette)
- Newsgroups: comp.lang.scheme
- Subject: Re: Summary. Interpreters are faster than I thought
- Message-ID: <4110@mitech.com>
- Date: 18 Dec 92 12:40:49 GMT
- References: <4094@mitech.com>
- Organization: Mitech Corporation, Concord MA
- Lines: 31
-
- In article <4094@mitech.com>, gjc@mitech.com (George J. Carrette) writes:
- > So here is another version of fib that uses binary arithmetic
- > implemented as lists of symbols. It runs around 50 times slower
- > than using built-in arithmetic.
- >
-
- I posted a fairly bogus version of "b-", which not only was ugly, it
- did not work on schemes that returned #unspecified instead of #f when
- falling off the end of a "if" form that had 2 instead of 3 legs.
-
- Here is JAR's much nicer version:
-
- ;From: UUCP%"jar@cs.cornell.edu" 18-DEC-1992 02:32
- ;To: gjc@mitech.com
-
- ;That's a really ugly b<, try this one.
-
- (define (b< x y)
- (and (not (null? y))
- (or (null? x)
- (b< (cdr x) (cdr y))
- (and (equal? (cdr x) (cdr y))
- (eq? (car x) 'A)
- (eq? (car y) 'B)))))
-
- (define (number->b n)
- (if (zero? n)
- '()
- (cons (if (odd? n) 'B 'A)
- (number->b (quotient n 2)))))
-
-