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
src2.8.1\scala-library-src\scala\actors\Future.scala" | |
157,12 def awaitEither[A, B >: A](ft1: Future[A], ft2: Future[B]): B = { | |
src2.8.1\scala-library-src\scala\collection\immutable\List.scala" | |
549,32 def lefts[A, B](es: Iterable[Either[A, B]]) = | |
559,33 def rights[A, B](es: Iterable[Either[A, B]]) = | |
571,34 def separate[A,B](es: Iterable[Either[A, B]]): (List[A], List[B]) = | |
src2.8.1\scala-library-src\scala\concurrent\ops.scala" | |
28,40 private def tryCatch[A](body: => A): Either[Throwable, A] = | |
31,48 private def getOrThrow[T <: Throwable, A](x: Either[T, A]): A = | |
56,25 val y = new SyncVar[Either[Throwable, B]] |
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
//2.9.0以上じゃないと動かないよーーー | |
//ぱふ のalias | |
type -->[A,B] = PartialFunction[A,B] | |
//Throwableを受け取って、エラーメッセージを返す ぱふ | |
val getErrorMsg: Throwable --> String = {case e:Throwable => e.getMessage } | |
//関数合成で、エラーメッセージをプリントする関数作成 | |
val printMsg = getErrorMsg.andThen(print) |
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で作っちゃうほどにScala中毒((((;゚Д゚)))) | |
def netstat = { | |
val p = Runtime.getRuntime.exec("netstat") | |
val lines = io.Source.fromInputStream( p.getInputStream ).getLines.toSeq | |
( lines.size , lines ) |
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
object SourceCode{ | |
val browser = """ "C:\Documents and Settings\scalaちゃん\Local Settings\Application Data\Google\Chrome\Application\chrome.exe" """ | |
val srcURL = "https://lampsvn.epfl.ch/trac/scala/browser/scala/tags/R_2_8_1_final/src//library/" | |
def apply(clazz:Class[_]){ | |
val url = srcURL + clazz.getName.replace('.','/') + ".scala#L1" | |
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
Seq( 5, 3, 6, 3, 6, 3, 1, 4, 7 ).map{ i => | |
() => concurrent.ops.spawn{ | |
Thread.sleep(i * 100) | |
print(i+",") | |
} | |
}.foreach(_.apply) | |
//1,3,3,3,4,5,6,6,7, |
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
sealed trait ReturnType{ | |
type A | |
val func:(String => A) | |
} | |
object ReturnType{ | |
object IntType extends ReturnType{ type A = Int ; val func = (_:String).toInt } | |
object LongType extends ReturnType{ type A = Long ; val func = (_:String).toLong } | |
object StringType extends ReturnType{ type A = String ; val func = identity[String] _ } | |
} |
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
object Test{ | |
def hoge [@specialized(AnyRef) T](arr: Array[T]){ | |
println(arr) | |
} | |
} |
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/Predef.scala: type OptManifest[T] = scala.reflect.OptManifest[T] | |
./scala/Predef.scala: def optManifest[T](implicit m: OptManifest[T]) = m | |
./scala/reflect/ClassManifest.scala:trait ClassManifest[T] extends OptManifest[T] with Equals with Serializable { | |
./scala/reflect/ClassManifest.scala: private def subargs(args1: List[OptManifest[_]], args2: List[OptManifest[_]]) = (args1 corresponds args2) { | |
./scala/reflect/ClassManifest.scala: def typeArguments: List[OptManifest[_]] = List() | |
./scala/reflect/ClassManifest.scala: def classType[T <: AnyRef](clazz: JClass[_], arg1: OptManifest[_], args: OptManifest[_]*): ClassManifest[T] = | |
./scala/reflect/ClassManifest.scala: def classType[T <: AnyRef](prefix: OptManifest[_], clazz: JClass[_], args: OptManifest[_]*): ClassManifest[T] = | |
./scala/reflect/ClassManifest.scala: def arrayType[T](arg: OptManifest[_]): ClassManifest[Array[T]] = arg match { | |
./scala/reflect/ClassManifest.scala: def abstractType[T](prefix: OptManifest[_], name: String, clazz: JClass[ |
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
Welcome to Scala version 2.9.0.r0-b20110520175005 (Java HotSpot(TM) Client VM, Java 1.6.0_22). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> :power | |
** Power User mode enabled - BEEP BOOP WHIR ** | |
** scala.tools.nsc._ has been imported ** | |
** global._ and definitions._ also imported ** | |
** New vals! Try repl, intp, global, power ** | |
** New cmds! :help to discover them ** |
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> import scala.util.control.Exception._ | |
import scala.util.control.Exception._ | |
scala> val superCatcher = catchingPromiscuously(classOf[InterruptedException]).or(allCatch) | |
superCatcher: util.control.Exception.Catch[Nothing] = Catch() | |
scala> superCatcher.either{ "hoge" toInt } | |
res0: Either[Throwable,Int] = Left(java.lang.NumberFormatException: For input string: "hoge") | |
scala> superCatcher.either{ throw new InterruptedException } |