map

Function map 

Source
pub fn map<T, U, F>(data: &[T], f: F) -> Vec<U>
where F: Fn(&T) -> U,
Expand description

Maps elements using a function.

ยงExample

use d3rs::array::map;

let data = vec![1, 2, 3, 4, 5];
let squares = map(&data, |x| x * x);
assert_eq!(squares, vec![1, 4, 9, 16, 25]);