knapply
11/5/2018 - 6:28 PM

Length from scratch (ish)

Length from scratch (ish)

#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
int cpp_length(NumericVector x) {
  int out = 0;
  for (NumericVector::iterator iter = x.begin(); iter != x.end(); iter++) {
    out++;
  }
  return out;
}

/*** R
cpp_length(1:20)
#> [1] 20
*/