How to make variable-length enums?

I found out that the Sequence.joined methods only work with inner sequences that are the same type. This meant that I couldn't connect my CollectionOfOne with 2 with a sequence of the odd primes, since they were different sequence types (with the same element type). I made a custom sequence that takes two source sequences. Then I wondered about making the resulting sequence a collection if both sources were collections. I could make the Index a two-state enum.

Then I thought about variadic generics again. The last proposal I saw had an example of an arbitrary-length ZipSequence. I wanted an example of a in-series multiplex sequence. It wouldn't be that hard, unless you wanted to conditionalize on Collection; then we would need an enum with an arbitrary number of cases. How could we do that with variadic generics?

As an alternative, I guess we could create a sum-tuple type. The in-series multiplexed collection type's Index would use a sum-tuple and a tag integer to indicate which case should be active. We would still need to figure out how to translate the tag index to the particular sum-tuple case to dereference.

Terms of Service

Privacy Policy

Cookie Policy