Created
June 27, 2010 10:39
-
-
Save retronym/454818 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> import scalaz._; import Scalaz._ | |
import scalaz._ | |
import Scalaz._ | |
scala> val t1 = (1, 2, 3) | |
t1: (Int, Int, Int) = (1,2,3) | |
scala> val t2 = (1, "a", false) | |
t2: (Int, java.lang.String, Boolean) = (1,a,false) | |
scala> t1 mapAll() | |
res0: (Int, Int, Int) = (1,2,3) | |
scala> t1 mapAll(_1 = 1+) | |
res1: (Int, Int, Int) = (2,2,3) | |
scala> t1 mapAll(_2 = 1+) | |
res2: (Int, Int, Int) = (1,3,3) | |
scala> t2 copy(_2 = "b") | |
res3: (Int, java.lang.String, Boolean) = (1,b,false) | |
scala> t2 copy(_2 = 0.5) | |
res4: (Int, Double, Boolean) = (1,0.5,false) | |
scala> t1 toIndexedSeq | |
res5: IndexedSeq[Int] = Vector(1, 2, 3) | |
scala> t2.toIndexedSeq | |
res6: IndexedSeq[Any] = Vector(1, a, false) | |
scala> (1, 2) mapAll(_ * 2, _ * 3) | |
res7: (Int, Int) = (2,6) | |
scala> t2 fold (_.toString + _ + _.toString) | |
res8: java.lang.String = 1afalse |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment