Created
June 2, 2014 16:02
-
-
Save takashima0411/bbb2d26590443ea8d5ca 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
import scala.util.Random | |
object Main { | |
val random = new scala.util.Random | |
def main(args:Array[String]):Unit = { | |
Iterator.continually(findSTAP).takeWhile(_ != "STAP").toList | |
println("見つかったよ!") | |
} | |
def findSTAP():String = { | |
val str = randomAlphanumericString(4) | |
print(str + "細胞") | |
str | |
} | |
def randomString(alphabet: String)(n: Int): String = | |
Stream.continually(random.nextInt(alphabet.size)).map(alphabet).take(n).mkString | |
def randomAlphanumericString(n: Int) = | |
randomString("ABCDEFGHIJKLMNOPQRSTUVWXYZ")(n) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment