From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jan Wedekind Newsgroups: gmane.lisp.guile.user Subject: Re: Simulating rational number addition/subtraction Date: Thu, 25 Feb 2016 06:52:40 +0000 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1456383197 18139 80.91.229.3 (25 Feb 2016 06:53:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 25 Feb 2016 06:53:17 +0000 (UTC) To: Lawrence Bottorff ,guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Feb 25 07:53:09 2016 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aYpnR-00081t-2m for guile-user@m.gmane.org; Thu, 25 Feb 2016 07:53:09 +0100 Original-Received: from localhost ([::1]:40495 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYpnQ-0001bz-ML for guile-user@m.gmane.org; Thu, 25 Feb 2016 01:53:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYpnH-0001bK-PE for guile-user@gnu.org; Thu, 25 Feb 2016 01:53:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYpnD-0001M7-PR for guile-user@gnu.org; Thu, 25 Feb 2016 01:52:59 -0500 Original-Received: from basicbox4.server-home.net ([195.137.212.26]:60193) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYpnD-0001Ko-J9 for guile-user@gnu.org; Thu, 25 Feb 2016 01:52:55 -0500 Original-Received: from [192.168.1.215] (unknown [95.150.200.130]) by basicbox4.server-home.net (Postfix) with ESMTPA id CE6D9153066B; Thu, 25 Feb 2016 07:52:50 +0100 (CET) User-Agent: K-9 Mail for Android In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 195.137.212.26 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:12444 Archived-At: On 24. Februar 2016 22:27:45 GMT+00:00, Lawrence Bottorff wrote: >With guile (and a few other Schemes/Lisps) you can directly add >fractions >or rational numbers: > >(+ 1/2 1/12) >=3D> 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 --=20 Jan Wedekind http://www.wedesoft.de/