Open zekefast opened 3 months ago
Hmm, curious. By the name cons
I'd have expected it to only support (a, (b, (c, d)))
order, since that want cons
ing creates in lisp.
Hmm, curious. By the name cons I'd have expected it to only support (a, (b, (c, d))) order, since that want consing creates in lisp.
Yeah, you are right. Probably it would be better to create some other functions to do that.
@scottmcm What do you thing about implementing flatten
for nested tuples?
Just my two cents: cons_tuples
seems (yet again) to be a "special-case map", and with these I increasingly think we should not offer them (or at least implement it as MapSpecialCase
). My argument: Why should concatenating tuples be tied to iterators? - Tuples originate elsewhere, too.
I imagine that a dedicated fn cons_tuples((A1, A2,...), (B1, B2,...))->(A1, A2,..., B1, B2,...)
would be the way to go, and if users want to use it with iterators, they can use iter.map(cons_tuples)
.
As for flatten
: Might be a candidate for tupletools, but I think fleshing out the details for it begs some more questions, i.e. how to deal with the exponentially (?) many combinations of tuple nestings?
Example from documentation
((A, B), C) -> (A, B, C)
works pretty well!but when order of tuples changes the code starts fall apart.
with the following error
Would it possible to make it work for different structure of the tuples?
If you have some suggestions on implementations, I'm willing to make a PR.
And big thank you to all maintainers for the great library!!!