[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Divide by zero or how to overload a function
From: |
Brett Viren |
Subject: |
Re: Divide by zero or how to overload a function |
Date: |
Mon, 22 Oct 2001 14:31:55 -0400 |
Robert A. Uhl writes:
> (set! / (let ((real-divide /)) (lambda your code here)))
Yes, thanks, this works okay:
(set! / (let ((the-real-/ /))
(lambda (a . l)
(letrec ((div (lambda (a l)
(cond ((equal? l '()) a)
((zero? (car l)) 0)
(else
(set! a (the-real-/ a (car l)))
(div a (cdr l)))))))
(div a l)))))
and allows the code to be loaded more than once. Although, one
slightly negative thing is that after each subsequent reloading of the
code, processing goes through the fake "/" more and more times in
order to get to the real "/". But, I can live with this.
Thanks,
-Brett.
Re: Divide by zero or how to overload a function, Robert A. Uhl, 2001/10/22