This file contains hidden or 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
| Apples-MacBook-Pro:~ debasishg$ scala | |
| Welcome to Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_45). | |
| Type in expressions to have them evaluated. | |
| Type :help for more information. | |
| scala> :paste | |
| // Entering paste mode (ctrl-D to finish) | |
| implicit class RContext(sc: StringContext) { | |
| def r = |
This file contains hidden or 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
| mapReduce :: (k1 -> v1 -> [(k2, v2)]) -- The Map function | |
| -> (k2 -> [v2] -> Maybe v3) -- The Reduce function | |
| -> Map k1 v1 -- a key to input - value mapping | |
| -> Map k2 v3 -- a key to output - value mapping |
This file contains hidden or 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
| mapReduce :: (k1 -> v1 -> [(k2, v2)]) -- The Map function | |
| -> (k2 -> [v2] -> [v2]) -- The Reduce function | |
| -> [(k1, v1)] -- a set of input key/value pairs | |
| -> [(k2, v2)] -- a set of output key/value pairs |
This file contains hidden or 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
| [error] /Users/debasishg/.../mapreduce/src/main/scala/com/eligotech/hnavigator/jobmanager/mapreduce/mr/RowProcess.scala:48: type mismatch; | |
| [error] found : A1(in method applyOrElse)(in method applyOrElse)(in method applyOrElse)(in method applyOrElse)(in method applyOrElse)(in method applyOrElse)(in method applyOrElse)(in method applyOrElse) => Boolean | |
| [error] required: A1(in method applyOrElse)(in method applyOrElse)(in method applyOrElse)(in method applyOrElse)(in method applyOrElse)(in method applyOrElse)(in method applyOrElse)(in method applyOrElse) => Boolean | |
| [error] } filter {tfstat => |
This file contains hidden or 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
| [info] Starting scala interpreter... | |
| [info] | |
| Welcome to Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_43). | |
| Type in expressions to have them evaluated. | |
| Type :help for more information. | |
| scala> import scala.util.Try | |
| import scala.util.Try | |
| scala> import scala.util.{Success, Failure} |
This file contains hidden or 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
| [info] Starting scala interpreter... | |
| [info] | |
| Welcome to Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_43). | |
| Type in expressions to have them evaluated. | |
| Type :help for more information. | |
| scala> import scalaz._ | |
| import scalaz._ | |
| scala> import Scalaz._ |
This file contains hidden or 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> :paste | |
| // Entering paste mode (ctrl-D to finish) | |
| val doOne = (user: String) => List("one" + "*" + user) | |
| val doTwo = (user: String) => List("two" + "*" + user) | |
| val doThree = (user: String) => List("three" + "*" + user) | |
| def collectAll(funs: List[String => List[String]])(user: String): List[String] = | |
| (List[String]() /: funs)((a, b) => a ::: b(user)) |
This file contains hidden or 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
| 14:26 ~/Projects/210x (2.10.x)$ scala | |
| Welcome to Scala version 2.10.1-20130204-105326-3d318be51f (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_37). | |
| Type in expressions to have them evaluated. | |
| Type :help for more information. | |
| scala> case class Shop(store: String, item: String, cost: Int) { def this() = this(null, null, 0) } | |
| defined class Shop | |
| scala> val t = typeOf[Shop] | |
| t: reflect.runtime.universe.Type = Shop |
This file contains hidden or 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
| import scala.reflect.runtime.universe._ | |
| import scala.reflect.api.{TypeCreator, Universe} | |
| object Test extends App { | |
| def foo[T: TypeTag] = TypeTag(typeTag[T].mirror, new TypeCreator { | |
| override def apply[U <: Universe with Singleton](m: scala.reflect.api.Mirror[U]): U # Type = { | |
| typeTag[T].in(m).tpe match { | |
| case TypeRef(_, _, argHead :: Nil) => argHead.asInstanceOf[U#Type] | |
| } | |
| } |
This file contains hidden or 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> case class Shop(store: String, item: String, cost: Int) { | |
| | def this() = this(null, null, 0) | |
| | } | |
| defined class Shop | |
| scala> val t = typeOf[Shop] | |
| t: reflect.runtime.universe.Type = Shop | |
| scala> val m = runtimeMirror(getClass.getClassLoader) | |
| m: reflect.runtime.universe.Mirror = JavaMirror with scala.tools.nsc.interpreter |