From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Newsgroups: gmane.lisp.guile.user Subject: Re: Simulating rational number addition/subtraction Date: Wed, 24 Feb 2016 18:32:12 -0500 Message-ID: <20160224233212.D0GOI.246997.root@cdptpa-web08> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1456356762 17881 80.91.229.3 (24 Feb 2016 23:32:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 24 Feb 2016 23:32:42 +0000 (UTC) To: guile-user@gnu.org, Lawrence Bottorff Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Feb 25 00:32:32 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 1aYiv1-0001o4-5D for guile-user@m.gmane.org; Thu, 25 Feb 2016 00:32:31 +0100 Original-Received: from localhost ([::1]:39022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYiv0-0000fR-3b for guile-user@m.gmane.org; Wed, 24 Feb 2016 18:32:30 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYiuq-0000fG-I5 for guile-user@gnu.org; Wed, 24 Feb 2016 18:32:21 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYiul-00062B-Fi for guile-user@gnu.org; Wed, 24 Feb 2016 18:32:20 -0500 Original-Received: from cdptpa-outbound-snat.email.rr.com ([107.14.166.232]:64968 helo=cdptpa-oedge-vip.email.rr.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYiul-00061r-Af for guile-user@gnu.org; Wed, 24 Feb 2016 18:32:15 -0500 Authentication-Results: cdptpa-oedge02 smtp.user=dsmich@roadrunner.com; auth=pass (LOGIN) Original-Received: from [107.14.174.248] ([107.14.174.248:47423] helo=cdptpa-web08) by cdptpa-oedge02 (envelope-from ) (ecelerity 3.5.0.35861 r(Momo-dev:tip)) with ESMTPA id D1/9F-13163-C7D3EC65; Wed, 24 Feb 2016 23:32:12 +0000 In-Reply-To: X-Priority: 3 (Normal) Sensitivity: Normal X-Originating-IP: from 40.129.68.106 by webmail.roadrunner.com; Wed, 24 Feb 2016 23:32:12 +0000 X-RR-Connecting-IP: 107.14.168.130:2525 X-Cloudmark-Score: 0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 107.14.166.232 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:12442 Archived-At: ---- Lawrence Bottorff 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 This https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-14.html might be enlightening.... -Dale