Skip to content

Instantly share code, notes, and snippets.

@halcat0x15a
Created December 20, 2011 13:10
Show Gist options
  • Save halcat0x15a/1501521 to your computer and use it in GitHub Desktop.
Save halcat0x15a/1501521 to your computer and use it in GitHub Desktop.
lazy val f: Int => Int = _ + 2
lazy val g: Int => Int = _ * 2
(f >>> g).apply(5) assert_=== 14
(f <<< g).apply(5) assert_=== 12
(f.promise >>> g.promise).apply(3).get assert_=== (f.promise >=> g.promise).apply(3).get
"1" |+| "2" assert_=== "12"
(("1".dual |+| "2".dual): String) assert_=== "21"
(f.endo.dual |+| g.endo.dual).apply(5) assert_=== 14
(f |+| g).apply(5) assert_=== 17
(f.endo |+| g.endo).apply(5) assert_=== 12
mzero[Endo[Int]].apply(5) assert_=== 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment