Skip to content

Commit

Permalink
Datafilter vectors - rev()
Browse files Browse the repository at this point in the history
.. rev(vector) - returns the vector with the sequence reversed.
  • Loading branch information
liversedge committed May 15, 2020
1 parent 2b68037 commit f3e9ba3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Core/DataFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ static struct {
// and values less than zero will be discarded, for the last bin any value greater
// than the value will be included. It is up to the user to manage this.

{ "rev", 1 }, // rev(vector) - returns vector with sequence reversed

// add new ones above this line
{ "", -1 }
};
Expand Down Expand Up @@ -3075,6 +3077,20 @@ Result Leaf::eval(DataFilterRuntime *df, Leaf *leaf, float x, long it, RideItem
return returning;
}

// rev - reverse the vector
if (leaf->function == "rev") {
Result returning(0);
Result value= eval(df, leaf->fparms[0],x, it, m, p, c, s, d);
if (value.vector.count() > 0){
for(int i=value.vector.count()-1; i>=0; i--) {
double v = value.vector.at(i);
returning.vector << v;
returning.number += v;
}
}
return returning;
}

// length
if (leaf->function == "length") {
double len = eval(df, leaf->fparms[0],x, it, m, p, c, s, d).vector.count();
Expand Down

0 comments on commit f3e9ba3

Please sign in to comment.