tables::column::apply

template <is_primitive_type P>
template<typename F>
  requires (
    std::invocable<F,prim_t> &&
    is_primitive_type<std::invoke_result_t<F,prim_t>>
  )
auto column<P>::apply(F f) const

Return column with elements x replaced by f(x)

Complexity

Linear

Example

Code

#include <cpptables/table.hh>

using namespace tables;
using namespace std;

void column_apply()
{
  const column<unsigned> xs ({ 1, 2, 3, 4, 5});

  const auto f = [] (unsigned x) { return 2*x; };
  const column<unsigned> ys = xs.apply(f);
  cout << ys << "\n";
}

Output

2 4 6 8 10