SHARE
TWEET

Untitled

a guest Jun 18th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. val ls = List(0, -1, 2, -2)
  2. var removeNegative = List[Int]()
  3. def removeNegative(ls: List[Int]): Int = ls match {
  4.  
  5.  
  6.   case Nil => 0
  7.   case l::for(ls <- ls){
  8.     var removeNegative = List[Int]()
  9.         if(ls >= 0){
  10.                 removeNegative = removeNegative :+ ls
  11.         }
  12.     }
  13.  
  14.  
  15.     return removeNegative
  16. }
  17.  
  18.  
  19. println(removeNegative(ls)
  20.      
  21. ScalaFiddle.scala:7: error: illegal start of simple pattern
  22.     case l::for(ls <- ls){
  23.             ^
  24. ScalaFiddle.scala:16: error: '=>' expected but '}' found.
  25.   }
  26.   ^
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top