Skip to content

Instantly share code, notes, and snippets.

@earino
Created January 6, 2014 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save earino/8276264 to your computer and use it in GitHub Desktop.
Save earino/8276264 to your computer and use it in GitHub Desktop.
String Slicer in C++
#include <Rcpp.h>
#include <iostream>
using namespace Rcpp;
using namespace std;
.
// [[Rcpp::export]]
std::string string_slicer( std::string input, std::vector< int > start, std::vector< int > end) {
std::string working_copy = input;
for(std::vector<int>::size_type i = start.size() - 1; i != (std::vector<int>::size_type) -1; i--) {
working_copy.erase(start[i]-1, (end[i] - start[i])+1);.
}
return working_copy;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment