SHARE
TWEET

Untitled

a guest Jun 17th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #![feature(slice_patterns)]
  2.  
  3. fn f<T>(_: &T, _: &T) -> T {
  4.     unimplemented!();
  5. }
  6.  
  7. use itertools::Itertools;
  8.  
  9. fn test<T>(vec: Vec<T>) -> Vec<Vec<T>>
  10. where
  11.     T: Clone,
  12. {
  13.     let n = vec.len();
  14.     let mut vec: Vec<_> = vec.into_iter().combinations(n).collect();
  15.  
  16.     for (i, it) in vec.iter_mut().enumerate() {
  17.         let (left, rigth) = it.split_at_mut(i);
  18.         if let [y, rigth..] = &mut rigth[..] {
  19.             for x in left.iter_mut().chain(rigth.iter_mut()) {
  20.                 *x = f(x, &y);
  21.             }
  22.         }
  23.     }
  24.  
  25.     vec
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top