Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Oct 11th, 2018 64 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. fn compose<P,R0,R1,F0,F1,FR>(mut f0:F0,mut f1:F1)->FR
  2. where
  3.     F0:FnMut(P)->R0,
  4.     F1:FnMut(R0)->R1,
  5.     FR:FnMut(P)->R1,
  6. {
  7.     move|x|{
  8.         let x=f0(x);
  9.         f1(x)
  10.     }
  11. }
  12. fn main(){
  13.     let mut func=compose(|x|x+2,|x|x*2);
  14.     assert_eq!(4,func(0));
  15.     assert_eq!(6,func(1));
  16.     assert_eq!(8,func(2));
  17. }
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