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> object scala {type Int = String} | |
scala> val dd:scala.Int = 33 | |
<console>:11: error: type mismatch; | |
found : scala.Int(33) | |
required: scala.Int | |
val dd:scala.Int = 33 | |
^ |
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
libraryDependencies += "org.scala-tools.testing" %% "scalacheck" % "1.9" |
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
def maxDupStr(str:String) = { | |
def tails:String => List[String] = { | |
case "" => Nil | |
case x => x :: tails(x.tail) | |
} | |
val sorted = tails(str) sorted | |
val pair = sorted zip sorted.tail | |
val maxPair = { | |
pair map { case (s1,s2) => (s1 zip s2 filter {c => c._1 == c._2} size, s1)} max | |
} |
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> val f:Int => Int = x => x | |
f: (Int) => Int = <function1> | |
この関数に数値を代入して、同じ関数を返す事が出来ないとダメなので解決出来ない。 | |
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
libraryDependencies += "net.liftweb" %% "lift-json" % "2.4" |
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
resolvers += "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/" | |
libraryDependencies += "org.scalaz" %% "scalaz-core" % "6.0.4" | |
libraryDependencies += "com.github.scala-incubator.io" %% "scala-io-core" % "0.3.0" | |
libraryDependencies += "com.github.scala-incubator.io" %% "scala-io-file" % "0.3.0" | |
libraryDependencies += "org.scala-tools.testing" %% "scalacheck" % "1.9" |
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
package storm.scala.examples | |
import storm.scala.dsl._ | |
import backtype.storm.Config | |
import backtype.storm.LocalCluster | |
import backtype.storm.topology.TopologyBuilder | |
import backtype.storm.tuple.{Fields, Tuple, Values} | |
import com.redis._ | |
import collection.mutable.{Map, HashMap} | |
import util.Random |
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 sbt._ | |
import Keys._ | |
object ScalaStromBuild extends Build { | |
lazy val root = Project(id = "ScalaStorm", base = file(".")) aggregate (scalaRedis) dependsOn(scalaRedis) | |
lazy val scalaRedis = Project(id = "scala-redis", base = file("scala-redis")) | |
} |
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
def hb(i1:String,i2:String) = (i1 zip i2).foldLeft((0,0)){(a, b) => if(b._1 == b._2) (a._1+1,a._2) else (a._1,a._2+1)} | |
def s(n:Int) = (1 to n).foldLeft(List("")){(l,_) => List("A","C","G","T").flatMap(x => l.map(_ + x))}.filter(_.contains("AAG")) |
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.annotation.tailrec | |
object PrimeTest extends App { | |
def primeDec(n: Int) = { | |
@tailrec | |
def r(in: Int, plist: List[Int], result: List[Int] = List()): List[Int] = { | |
plist match { | |
case x :: xs if in % x == 0 => r(in / x, plist, x :: result) | |
case x :: xs if in % x != 0 => r(in, xs, result) |