tcbrindle / flux

A C++20 library for sequence-orientated programming
https://tristanbrindle.com/flux/
Boost Software License 1.0
479 stars 29 forks source link

Add seq._(fn, args...) member function #18

Closed tcbrindle closed 1 year ago

tcbrindle commented 1 year ago

This allows adding custom operations as part of a pipeline using the "dot" syntax, for example

auto res = get_sequence()
            .filter(...)
            .map(...)
            ._(custom_op, arg1, arg2)
            .fold(...)

which will call custom_user_op(seq, arg1, arg2) with the adapted sequence as the first argument, followed by the provided args.

I previously had this in Flow as x.apply(fn, args...), but Barry's idea from his Rivers library to name it just x._(fn, args...) is much better.

codecov[bot] commented 1 year ago

Codecov Report

Base: 96.93% // Head: 96.93% // No change to project coverage :thumbsup:

Coverage data is based on head (9f24e50) compared to base (48dedb3). Patch has no changes to coverable lines.

:exclamation: Current head 9f24e50 differs from pull request most recent head 19a3f24. Consider uploading reports for the commit 19a3f24 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #18 +/- ## ======================================= Coverage 96.93% 96.93% ======================================= Files 48 48 Lines 1402 1402 ======================================= Hits 1359 1359 Misses 43 43 ``` | [Impacted Files](https://codecov.io/gh/tcbrindle/libflux/pull/18?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tristan+Brindle) | Coverage Δ | | |---|---|---| | [include/flux/core/lens\_base.hpp](https://codecov.io/gh/tcbrindle/libflux/pull/18/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tristan+Brindle#diff-aW5jbHVkZS9mbHV4L2NvcmUvbGVuc19iYXNlLmhwcA==) | `85.71% <ø> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tristan+Brindle). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tristan+Brindle)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.