Dobiasd / FunctionalPlus

Functional Programming Library for C++. Write concise and readable C++ code.
http://www.editgym.com/fplus-api-search/
Boost Software License 1.0
2.1k stars 167 forks source link

Grouped map to pairs #229

Closed unixnme closed 3 years ago

unixnme commented 3 years ago

Hello,

I added map_grouped_to_pairs function as we have discussed in #227 . I kept your description, but removed ContainerOut template (for simplicity) and re-implemented using existing functions.

Dobiasd commented 3 years ago

Thanks! I like the elegant implementation. :heart_eyes:

The restoration test (x |> map_grouped_to_pairs |> pairs_to_map_grouped) is also a good idea. :+1:

unixnme commented 3 years ago

but it's failing the ci test. :( it works fine on mine (macOS, clang12)

Dobiasd commented 3 years ago

Weird. It does look correct though. I guess it's just too much for some type-deduction implementations. Basically, we're running into compiler bugs.

Replacing

        return apply_to_pair(zip_repeat<std::vector<Key>, Group>,
                             transform_fst(singleton_seq<Key>, pair));

with

        const auto f = zip_repeat<std::vector<Key>, Group>;
        return apply_to_pair(f, transform_fst(singleton_seq<Key>, pair));

should do the trick. (At least it does on my machine.)

Dobiasd commented 3 years ago

Looks better. :+1:

If you move that one { to the next line, I guess we're good to merge.

unixnme commented 3 years ago

Looks better. 👍

If you move that one { to the next line, I guess we're good to merge.

Done :)

Dobiasd commented 3 years ago

Thanks.

Also, in general. It is very pleasant discussing things with you and seeing you using fplus so aptly. :-)