Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. pub fn map_column<'a, ColumnType: 'static, A: 'static, B: 'static>(
  2. column_data: &'a ColumnInformation<ColumnType>,
  3. column_idx: usize,
  4. indexes: &[usize],
  5. map_fn: A,
  6. ) -> Box<dyn Iterator<Item = B> + 'a>
  7. where
  8. A: Fn(ColumnType) -> B,
  9. ColumnType: std::clone::Clone,
  10. {
  11. let column_indexes: Vec<usize> = indexes
  12. .iter()
  13. .map(|idx| (column_data.columns * *idx) + column_idx)
  14. .collect::<Vec<usize>>();
  15.  
  16. Box::new(
  17. column_indexes
  18. .into_iter()
  19. .map(move |index| map_fn(column_data.predictors[index].clone())),
  20. )
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement