[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

This page is part of the web mail archives of SRFI 121 from before July 7th, 2015. The new archives for SRFI 121 contain all messages, not just those from before July 7th, 2015.

*To*: srfi-121@xxxxxxxxxxxxxxxxx*Subject*: Make-rational-number-generator*From*: John Cowan <cowan@xxxxxxxxxxxxxxxx>*Date*: Sat, 7 Feb 2015 20:17:15 -0500*Delivered-to*: srfi-121@xxxxxxxxxxxxxxxxx*Sender*: John Cowan <cowan@xxxxxxxx>*User-agent*: Mutt/1.5.20 (2009-06-14)

Here's something I found too late to put it into the first draft: (make-rational-number-generator [ q ] ) Returns a generator of rational numbers starting with q (default 0) according to the following recurrence: x' = (/ 1 (+ (* 2 (truncate x)) 1 (- x))) It will generate all exact rationals once and only once in in the infinite sequence 0, 1/2, 2, 1/3, 3/2, 3, 1/4, 4/3, 3/5, 5/2, 2/5, 3/4, 4, ... It is an error if q is negative or inexact. What do people think? -- John Cowan http://www.ccil.org/~cowan cowan@xxxxxxxx Fundamental thinking is ha-ard. Let's go ideology-shopping. --Philosopher Barbie

**Follow-Ups**:**Re: Make-rational-number-generator***From:*Alex Shinn

- Prev by Date:
**Re: SRFI 121: Generators** - Next by Date:
**Re: SRFI 121: Generators** - Previous by thread:
**Gbuffer-filter procedure** - Next by thread:
**Re: Make-rational-number-generator** - Index(es):