Am Di., 30. Jan. 2024 um 07:19 Uhr schrieb John Cowan <[email protected]>:
> Vectors of all types as well as arrays use SRFI 133 ordering; other > sequence types use SRFI 1 ordering. This is a consequence of how the SRFIs > were derived; e.g. SRFI 160 (heterogeneous arrays) was cloned from SRFI 133. > > What I would like to do is to use fold and fold-right for SRFI 1 order and > foldl and foldr for SRFI 133 order. > We already have fold-left in R6RS (which is what you would call foldl). Please reuse this name instead of adding just another new name. > > On Tue, Jan 30, 2024 at 1:14 AM Marc Nieper-Wißkirchen < > [email protected]> wrote: > >> Am Di., 30. Jan. 2024 um 02:12 Uhr schrieb Bradley Lucier < >> [email protected]>: >> >>> SRFI 1 has >>> ====================== >>> (fold kons knil lis) = (fold kons (kons (car lis) knil) (cdr lis)) >>> (fold kons knil '()) = knil >>> ====================== >>> with the example >>> ====================== >>> (fold cons '() lis) ; Reverse LIS. >>> ====================== >>> So the state, knil, is the rightmost argument (when there are multiple >>> list arguments to fold). >>> >>> SRFI 133 says >>> ====================== >>> kons is applied as (kons state (vector-ref vec1 i) (vector-ref vec2 i) >>> ...) where state is the current state value. >>> ====================== >>> So the state is the leftmost argument. >>> >>> I haven't gone through the SRFI 133 mail-list discussion, and there is >>> the example: >>> ====================== >>> Produce a list of the reversed elements of vec: >>> >>> (vector-fold (λ (tail elt) (cons elt tail)) '() vec) >>> ====================== >>> >>> So the argument order to vector-fold seems (a) reasonable as a choice, >>> and (b) incompatible with SRFI 1. >>> >>> Am I understanding this correctly? >>> >> >> Yes, this is correct. There have been initiatives to change SRFI 1 >> and/or SRFI 133 within R7RS-large. >> >> Marc >> >
