You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today's Advent of Code was a reminder that even with flux::unpack, working with sequences which yield tuples can be really ugly:
To avoid this, we could automatically unpack tuples in sequence adaptors where possible, allowing users to write something like
auto seq = flux::zip(get_vector(), get_string())
.map([](int i, char c) { ... });
that is, without needing to wrap the lambda in flux::unpack.
I think the best way to do this is to add our own flux::invoke(f, args...) which:
First tries std::invoke(f, args...)
If that fails, and if the args... pack has exactly one element, tries again with std::invoke(unpack(f), args...)
We'd also need corresponding versions of invoke_result_t and the invocable concept.
If we make this change, it would also be worth looking at the codegen of e.g cartesian_product_map and zip_map vs cartesian_product.map and zip.map to see whether it's worth keeping the former around.
The text was updated successfully, but these errors were encountered:
Today's Advent of Code was a reminder that even with
flux::unpack
, working with sequences which yield tuples can be really ugly:To avoid this, we could automatically unpack tuples in sequence adaptors where possible, allowing users to write something like
that is, without needing to wrap the lambda in
flux::unpack
.I think the best way to do this is to add our own
flux::invoke(f, args...)
which:std::invoke(f, args...)
args...
pack has exactly one element, tries again withstd::invoke(unpack(f), args...)
We'd also need corresponding versions of
invoke_result_t
and theinvocable
concept.If we make this change, it would also be worth looking at the codegen of e.g
cartesian_product_map
andzip_map
vscartesian_product.map
andzip.map
to see whether it's worth keeping the former around.The text was updated successfully, but these errors were encountered: