Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Compile and Execute Scala Online

import scala.collection.mutable.ArrayBuffer
import scala.collection.mutable.ListBuffer
object HelloWorld {
   def main(args: Array[String]) {
      val rdd = "c71amt"
      val parsed = rdd.replaceAll("[0-9$&+,:;=?@#|'<>.-^*()%!]","")
      val dictionary = List("camt", "tamc", "mact", "cmat", "catm")
      val list = parsed.toList
      var count = list.length*(list.length-1).toInt
      var ab = new ListBuffer[String]()
      var printer = new ListBuffer[String]()
      while(count > 0){
           var random = scala.util.Random.shuffle(list)
           var wordtomatch = random.mkString
           ab += wordtomatch
           ab = ab.distinct
            if(dictionary.contains(wordtomatch) == true){
                printer += wordtomatch
                count=count-1;
            }
            }
        printer = printer.distinct
        printer.foreach(println)
       }
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.