Comprehensions Jens Axel Søgaard (08 Dec 2021 20:58 UTC)
Re: Comprehensions Bradley Lucier (09 Dec 2021 01:10 UTC)
Re: Comprehensions Arthur A. Gleckler (09 Dec 2021 02:14 UTC)
Re: Comprehensions Bradley Lucier (09 Dec 2021 20:09 UTC)

Re: Comprehensions Bradley Lucier 09 Dec 2021 01:10 UTC

I think some version of this would be a great idea.  It would certainly
make intervals a more useful data structure in their own right.

With several people working on independent implementations of SRFI 179
and making suggestions, I plan to start a new SRFI process to finally
put this to bed.  I've been working in

https://github.com/gambiteer/srfi-179-followup/

and sending emails to this list to keep a record.

I came up with some names for the new SRFI that are kind of silly, but
in all seriousness I don't know what to call the new SRFI.  Some of the
silly names

Nonempty Intervals and Generalized Arrays (Revised^2)
Nonempty Intervals and Generalized Arrays (Redux)
Nonempty Intervals and Generalized Arrays (The Director's Cut)

Suggestions are very welcome.

Brad

On 12/8/21 3:58 PM, Jens Axel Søgaard wrote:
> Hi All,
>
> I have begun implementing srfi 179 for Racket.
>
> In Racket I prefer `for`-loops over loops using named lets.
>
> The Racket `for`-loops are based on srfi-42, which I was quite fond of
> back in my Scheme days.
> Is srfi-42 still in use?
> If so, iterators for intervals and comprehensions for arrays would be a
> nice addition.
>
> So far I have defined `in-interval` which iterates through the indices
> of an interval.
> Down the row I plan to add `in-row`, `in-column` and `in-array`.
>
> As an example the definition of `array-for-each`:
>
>     (define (interval-for-each f interval)
>        (unless (interval? interval)
>          (raise-argument-error 'interval-for-each
>                                "expected an interval as the second argument"
>                                "interval" interval))
>        (unless (procedure? f)
>          (raise-argument-error 'interval-for-each
>                                "expected a procedure as the first argument"
>                                "procedure" f))
>        (define d (interval-dimension interval))
>        (case d
>          [(1)  (for* ([(i)       (in-interval interval)]) (f i))]
>          [(2)  (for* ([(i j)     (in-interval interval)]) (f i j))]
>          [(3)  (for* ([(i j k)   (in-interval interval)]) (f i j k))]
>          [(4)  (for* ([(i j k l) (in-interval interval)]) (f i j k l))]
>          [else
>           (for ([is (in-interval/internal-vector interval)])
>             (apply f (vector->list is)))]))
>
>
>
> --
> Jens Axel Søgaard
>