I have a scala class:
Rts.scala
class Rts(buffer:Iterator[Tse]) extends Ts
{ //Some methods}
Now I am trying to put Tse list to the constructor of the above class from java class:
Tse tse1= new Tse(1285927200000L, 1285928100000L, 0.0);
Tse tse2 =…
I have a tool that is trying to build instances of sub-classes of various scala collections, for example scala.collection.Seq. I don't know in advance what specific class should be built, so I am trying to use reflection to get the apply method in…
I have a Scala case class and a corresponding Java class. I've declared an implicit conversion from Scala class to Java class. Now I have a Scala collection of Scala classes, and I want to convert them to Scala collection of Java classes. Is it…
I am trying to use a recursive function to go through each element in a List[Char], to check the number of occurrences of an element. I know there are easier ways and possibly even functions to do this, but would there be any way to delete just the…
I am learning Scala and I'm having some troubles to write a simple reducer function. I want to count how many times a value appear in a list. Thus, I wrote a reducer/folding function which takes an immutable map as initial value, and then iterates…
I am new to Scala. I have three List.
List("XX", None,None,None)
List( None,"YY",None,None)
List(None,None,None, "ZZ")
I need to merge these list to create a single list which should look like
List("XX","YY",None,"ZZ")
Is there any way in scala…
I need to form this:
{
“item” : “hardcoded_value”,
“item2” : “hardcoded_value”,
“item3” : “hardcoded_value”,
}
In the exec block I am trying:
// list with items [“item1”, “ item2”, “ item3”]
val theList = session("itemNames").as[List[String]]
val…
Im trying to map a JSONObject instance into an actual instance through Play Combinators. I am able to get the desrialization work correctly. The question is on the behavior of how map() works on an Option[JSONObject].
Option1:
jsonVal:…
object ScalaTest{
def main (args: Array[String]){
var i =0
while(i<=10){
println(i)
i +=1
}
}
}
When i do
c:\ Scalac ScalaTest.scala \\ it goes to the next line but
c:\ Scala ScalaTest.scala…
Is there a reason for a SortedMap with a default value becoming a regular unsorted Map?
scala> val a = scala.collection.immutable.SortedMap(1 -> "uno", 3 -> "tres", 2 -> "dos")
a: scala.collection.immutable.SortedMap[Int,String] = Map(1 -> uno, 2 ->…
I want to define a transformation of a generic collection.
def transform[S<:GenIterable[T],T](s:S):S = s.zipWithIndex
This throws:
type mismatch; found : scala.collection.GenIterable[(T, Int)] required: S
I have to declare S as a parameterized…
I have a PairRDD in the form RDD[(String, Array[String])]. I want to flatten the values so that I have an RDD[(String, String)] where each of the elements in the Array[String] of the first RDD become a dedicated element in the 2nd RDD.
For instance,…
I have a list of files names (nearly 400 000). I need to parse each file's content and find a given string pattern.
Can any one help me best way to boost my searching process(I'm able to process the content in 90 seconds).
Here is the piece of code…
I have this
list {
1,1
1,2
2,1
}
and I want to turn it into this
map {
1 -> (1,2)
2 -> (1)
}
What I tried so far:
val list = List((1,1),(1,2),(2,1))
var map: Map[Int, Seq[Int]] = Map()
for (e <- list) {
if (map contains e._1)
map…