fork download
  1. object Main {
  2.  
  3. def iter(a1: List[String], a2: List[String], acc: Int): Int = {
  4.  
  5. if(a2.length == 0) acc
  6. else if(a1.contains(a2.head)) iter(a1, a2.tail, acc+1)
  7. else iter(a1, a2.tail, acc)
  8. }
  9.  
  10. def nOfEqual(a1: List[String], a2: List[String]): Int = iter(a1, a2, 0)
  11.  
  12. def main(a: Array[String]) = {
  13. val file1 = scala.io.Source.fromFile(a(1), "utf-8").getLines.toList
  14. val file2 = scala.io.Source.fromFile(a(2), "utf-8").getLines.toList
  15. print("Copied "+nOfEqual(file1, file2)/file1.length.toDouble+"%")
  16. }
  17. }
Runtime error #stdin #stdout #stderr 0.1s 381120KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
	at Main$.main(Main.scala:13)
	at Main.main(Main.scala)