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

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

*To*: srfi-1@xxxxxxxxxxxxxxxxx*Subject*: Re: Folds and reductions*From*: John David Stone <stone@xxxxxxxxxxxxx>*Date*: Mon, 11 Jan 1999 11:59:08 -0600 (CST)*Reply-to*: stone@xxxxxxxxxxxxx

Now that I think about it, there are a couple of small improvements to be made in the code I wrote at http://srfi.schemers.org/srfi-1/mail-archive/msg00021.html: In PAIR-FOLDL, it's pointless to cons ANS onto LISTS in the call (APPLY F (CONS ANS LISTS)), since if consing is needed APPLY will do it internally: (define (pair-foldl f zero lis1 . lists) (if (pair? lists) (let lp ((lists (cons lis1 lists)) (ans zero)) (if (%all-pairs? lists) (let ((tails (%cdrs lists))) (lp tails (apply f ans lists))) ans)) (let lp ((lis lis1) (ans zero)) (if (pair? lis) (let ((tail (cdr lis))) (lp tail (f ans lis))) ans)))) Given my remarks in (1) and (2) of the earlier message, LIDENTITY would be a better identifier for the third parameter of REDUCEL: (define (reducel f lidentity lis) (if (pair? lis) (foldl f (car lis) (cdr lis)) lidentity)) -- ====== John David Stone - Lecturer in Computer Science and Philosophy ===== ============== Manager of the Mathematics Local-Area Network ============== ============== Grinnell College - Grinnell, Iowa 50112 - USA ============== ========== stone@xxxxxxxxxxxxx - http://www.math.grin.edu/~stone/ =========

- Prev by Date:
**Folds and reductions** - Next by Date:
**Will Fitzgerald <fitzgerald@xxxxxxxxxxxx>** - Previous by thread:
**Folds and reductions** - Next by thread:
**Will Fitzgerald <fitzgerald@xxxxxxxxxxxx>** - Index(es):