use crate::vector_impl::Vector;
impl<T> Vector<T> {
pub fn lambda<F>(&self, funct: F) -> Vector<T>
where
F: Fn(&T) -> T
{
let mut params = Vec::with_capacity(self.len());
for item in self.list() {
params.push(funct(item))
}
Vector::from(params)
}
pub fn lambda_index<F>(&self, funct : F) -> Vector<T>
where
F: Fn(usize) -> T
{
let mut params = Vec::with_capacity(self.len());
for item in 0..self.len() {
params.push(funct(item))
}
Vector::from(params)
}
pub fn lambda_enumerate<F>(&self, funct : F) -> Vector<T>
where
F: Fn(usize, &T) -> T
{
let mut params = Vec::with_capacity(self.len());
for (idx, item) in self.list.iter().enumerate() {
params.push(funct(idx, item))
}
Vector::from(params)
}
}