Function rustplot::data_parser::num_pred [] [src]

pub fn num_pred(vec1: &Vec<f64>, pred_func: fn(_: f64) -> bool) -> Vec<usize>

Returns a Vec (integer vector) with the index of each element matching the predicate function provided.

vec1 is a numerical vector for which each element will be checked with the predicate function.

pred_func is the predicate function applied to each element of the vector.

This function is designed for use with vec_remove_where() and vec_keep_where().

Examples

use rustplot::data_parser;

let num_row = data_parser::get_num_row(0, 0, 10, "./test.csv");

fn pred(num1: f64) -> bool {
    num1 <= 7.0
}
let f: fn(f64) -> bool = pred;

let matching_indexes = data_parser::num_pred(&num_row, f);