To make your vector+ operation take an arbitrary number of arguments, this
is what I'd do:
(define (vector+ . vectors)
(vector
(for/sum ([v (in-list vectors)]) (vector-i v))
(for/sum ([v (in-list vectors)]) (vector-j v))
(for/sum ([v (in-list vectors)]) (vector-k v
(module+
Turns out that I don't see a way to calculate the #:auto-value using the
constructor fields, so I don't see how to make something like
(struct test (x y z [data #:auto])
#:auto-value #(x y z))
work.
So I've decided to go with something like this:
(struct color (r g b) #:transparent)
(struct
Apologies. By fourth optional argument, I meant a fourth field with the
#auto field option. I'm experimenting with this now.
On Monday, February 1, 2021 at 3:24:49 PM UTC-6 making-a-racket wrote:
> Thanks for the suggestion and for the macro implementation. I'll have to
> pour over that a bit.
Thanks for the suggestion and for the macro implementation. I'll have to
pour over that a bit.
I wanted to do map because I wanted to make it easy to idiomatically
implement addition and other such operators on my data types such that they
accept arbitrary amounts of arguments and provide the
I'd suggest just going with the structs and making them transparent. It's
only three structs and only with a handful of fields, abstracting over them
with map and fold doesn't seem worth the added complexity IMO. But if you'd
really like to map and fold over structs, I highly recommend using
5 matches
Mail list logo