草生やす関数
草生やしたいときに
def www( s:String ):String = { import scala.util.Random val rnd = new Random( ) val ws = List( "w","W","w" ) def w(n:Int):String = ( 0 - n) until rnd.nextInt(3) map { i => ws( rnd.nextInt( ws.size -1 ) ) } mkString ("ちょ" + w(1) + "おま" + w(1) ) + ("" /: s ){ ( c,e ) => c + e + w(0) } + w(0) }
実行結果:
scala> www("誰得よこんなん") res1: String = ちょWWおまw誰得よWWこんwなんWwW