On 24. Februar 2016 22:27:45 GMT+00:00, Lawrence Bottorff <[email protected]> wrote: >With guile (and a few other Schemes/Lisps) you can directly add >fractions >or rational numbers: > >(+ 1/2 1/12) >=> 7/12 > >It's like magic, no? Anyway, I'm trying -- for educational purposes -- >to >reproduce this functionality. But right out of the blocks I'm stuck >trying >to figure out how to handle incoming parameters. So far I've got > >(define (myrat a b) > . . .) > >(define (myrat a b c d) > . . .) > >where numerator and denominator are given separately, as well as > >(define (myrat . fracparams) > . . .) > >which still has my basic problem, namely, can one parameter hold both >parts >of a rational number, then allow the numerator and denominator to be >peeled >off and worked on, i.e., something like > >(let ((num1 numepeeler(a)) > (denom1 denompeeler(a) > > >LB
You can use GOOPS (*) to represent the rational numbers. (*) http://www.gnu.org/software/guile/manual/html_node/GOOPS.html -- Jan Wedekind http://www.wedesoft.de/
