Inspired by underscore.js
┬ ┬┌┐┌┌┬┐┌─┐┬─┐┌─┐┌─┐┌─┐┬─┐┌─┐ ┌─┐┌─┐┌─┐ │ ││││ ││├┤ ├┬┘└─┐│ │ │├┬┘├┤ │ ├─┘├─┘ └─┘┘└┘─┴┘└─┘┴└─└─┘└─┘└─┘┴└─└─┘────└─┘┴ ┴
Implementation of:
- each
- transform
- filter_accept
- filter_reject
- find_if
- find_if_not
- every
- count_by
- contains
- max
- min
- intersect
- union
- size
- Clone the project using
git clone https://github.com/farziengineer/underscore_cpp
- To run the project you can individually compile the files(.cpp) and link them, or just run the bash file
runn.sh
usingbash runn.sh (on Linux)
.
void display(int x)
{
cout << x << " ";
}
std::vector<int> vec = {1, 2, 3};
underscore::each(vec, display);
Output: 1 2 3
int increment_by_one(int x)
{
return x + 1;
}
void display(int x)
{
cout << x << " ";
}
std::vector<int> vec = {1, 2, 3};
underscore::transform(vec, increment_by_one);
underscore::each(vec, display);
Output: 2 3 4