Is there an iterator that [...]

I need to collect two separate vecs. One vec is collected-into if predicate A is true, and the other vec is collected-into if predicate B is true. It is preferable that the conditions are evaluated in the same closure within the lambda expression

1 Like
5 Likes

Almost word-for-word on-spot.

A related one is Itertools::partition_map, which lets each side have distinct item and collection types.

1 Like

Now what would be interesting if this can be done in an optimized way such that you can partition X into (N, N1), and_then partition N into (K, K1) simultaneous to partitioning N1 into (Z, Z1). AKA, a double partition that results in a tuple of len 4: (K, K1, Z, Z1)

                   / ==> K
       / -- N ---->
      /            \ ==> K1
X ==>
      \             / ==> Z
       \ -- N1 ---->
                    \ ==> Z1

I actually did enable something like that in rayon with ParallelExtend for tuples. I think standard iterators could do the same with Extend, but I never actually proposed this.

Wow, you made rayon! YOU must be the one that eats the nomicon for breakfast, lol! And thank you btw for the help

1 Like

I'm one of the authors, yes. Yet I still try to keep a healthy caution around nomicon topics. :slightly_smiling_face:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.