fork download
  1. object Main extends App {
  2.  
  3. val l = List(
  4. (List("vmname"),"myNetwork3",10,"vSwitch0",List(),"192.168.20.2","cisco WS-C3560E-48PD","GigabitEthernet0/43","sky"),
  5. (List("vmname"),"myNetwork",0,"vSwitch0",List("name1", "name2", "name3", "name4"),"192.168.20.2","cisco WS-C3560E-48PD","GigabitEthernet0/43","sky")
  6. )
  7. def listcontains[T](word: String)(l: List[T]): Boolean = l map { a => a match {
  8. case s: String => s contains word
  9. case t: List[T] => listcontains(word)(t)
  10. }} reduce (_ || _)
  11.  
  12. println(l.filter(listcontains("name1")).toString())
  13.  
  14. }
Compilation error #stdin compilation error #stdout 0.4s 381952KB
stdin
Standard input is empty
compilation info
/opt/scala/bin/scalac: line 50: /dev/null: Permission denied
Main.scala:9: warning: abstract type T in type pattern List[T] is unchecked since it is eliminated by erasure
    	case t: List[T] => listcontains(word)(t)
                ^
Main.scala:12: error: polymorphic expression cannot be instantiated to expected type;
 found   : [T](l: List[T])Boolean
 required: ((List[String], String, Int, String, List[String], String, String, String, String)) => Boolean
    println(l.filter(listcontains("name1")).toString())
                                 ^
one warning found
one error found
spoj: The program compiled successfully, but Main.class was not found.
      Class Main should contain method: def main(args: Array[String]).
stdout
Standard output is empty