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

*To*: address@hidden*Subject*: Re: CPS != call/cc*From*: Guy Steele - Sun Microsystems Labs <address@hidden>*Date*: Tue, 19 Aug 2003 12:28:50 -0400 (EDT)*Cc*: address@hidden, address@hidden, address@hidden*Reply-to*: Guy Steele - Sun Microsystems Labs <address@hidden>*Sender*: address@hidden

Date: Wed, 6 Aug 2003 13:42:29 -0400 Subject: Re: CPS != call/cc Cc: "Peter J. Wasilko, Esq." <futurist@cloud9.net>, Dan Sugalski <dan@sidhe.org>, ll1-discuss@ai.mit.edu To: John Clements <clements@brinckerhoff.org> From: John Clements <clements@brinckerhoff.org> On Wednesday, August 6, 2003, at 01:10 PM, John Clements wrote: > > On Wednesday, August 6, 2003, at 11:00 AM, Peter J. Wasilko, Esq. > wrote: ... > > EXAMPLE: > > this program is in CPS (w.r.t. user-defined procedures): > > (define (fact-cps n k) > (if (= n 0) > (k 1) > (fact-cps (- n 1) (lambda (x) (* x n))))) ... of course I was going to make a mistake. Here's the correction: (define (fact-cps n k) (if (= n 0) (k 1) (fact-cps (- n 1) (lambda (x) (k (* x n)))))) Even more accurate would be: (define (fact-cps n k) (= n 0 (lambda (b) (if b (k 1) (- n 1 (lambda (m) (fact-cps m (lambda (x) (* x n k))))))))) That is, we assume that =, -, and * also take continuations. --Guy

- Prev by Date:
**Re: the benefits of immutability** - Next by Date:
**RE: the benefits of immutability** - Previous by thread:
**RE: first-class names** - Next by thread:
**Re: forewords by Guy L. Steele Jr.** - Index(es):