Skip to content

Instantly share code, notes, and snippets.

@kitelife
Created September 1, 2015 02:57
Show Gist options
  • Save kitelife/30a8ab0474c4f9b00b4b to your computer and use it in GitHub Desktop.
Save kitelife/30a8ab0474c4f9b00b4b to your computer and use it in GitHub Desktop.
object Test extends App {
val a = Array(10, 9, -1, 8, -2, -100, 1000).toBuffer
var first = true
val indexes = for (i <- 0 until a.length if first || a(i) >= 0) yield {
if (a(i) < 0)
first = false
i
}
for(j <- 0 until indexes.length)
a(j) = a(indexes(j))
a.trimEnd(a.length - indexes.length)
for(ele <- a) println(ele)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment