Skip to content

Instantly share code, notes, and snippets.

@knapply
Last active November 7, 2018 22:54
Show Gist options
  • Save knapply/da952ed9a5cc2a04d4aa72e653b5a649 to your computer and use it in GitHub Desktop.
Save knapply/da952ed9a5cc2a04d4aa72e653b5a649 to your computer and use it in GitHub Desktop.
#include <iostream> // std::cout, std::endl
#include <vector> // std::vector
using std::cout;
using std::endl;
using std::vector;
int length(vector<double> &x) {
int out = 0;
for (auto it = begin(x); it != end(x); ++it) {
out++;
}
return out;
}
int main() {
vector<double> v{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
int result = length(v);
cout << "length: " << result << endl;
return 0;
}
//> length: 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment