I have entry at file having four columns colA, colB, colC, colD. I need to read that file and create two immutable datastructure mappings.
colA -> (colB, colC, colD)
colB -> (colA, colC, colD)
Is there any way I can do that in one go.…
I have a list:
val list1 = List("male:Adam", "male:Peter", "female:Jane", "female:Sue", "female:Jo", "other:John")
I want to create two lists, one of female names and one of male names.
i.e.:
List("Adam", "Peter")
List("Jane", "Sue", "Jo")
I've…
Can't see the real difference between :: and +: method of Scala List.
I used REPL to test and can't see diff from the result.
Anyone can give me how can I use that properly?
I'm trying to catch some errors with try and i'm getting some error i dont know why, this is the code:
class Application extends Controller {
val ds: DataSource = CsvDataSource
val purchaseDS = PurchaseInfo.fromDataSource(ds)_
def index =…
If I have an List[Try[Int]] that represents some results from a function.
scala> import scala.util._
scala> val result = List[Try[Int]](
Success(1),
Failure(new RuntimeException("first exception")),
Success(2),
Failure(new…
I am learning Spark source code, and get confused on the following code:
/**
* Return a new RDD containing the distinct elements in this RDD.
*/
def distinct(numPartitions: Int)(implicit ord: Ordering[T] = null): RDD[T] =
map(x => (x,…
I want to count the language tags in Github repositories. I am using scalaj-http for that.
val response: HttpResponse[String] = Http("https://api.github.com/search/repositories?q=size:>=0").asString
val b = response.body, …
I'm having some issues converting from Scala to Java, and then back to Scala. I'm trying to convert from a Scala mutable buffer to a Java List, and then back to a Scala mutable buffer after I apply Java's nifty shuffling function.
I tried using…
I need to select a value from a drop down using gatling / scala. code as below. formParam seems not working for this type .can some one help me to solve this issue.i need to select Mobile Phone from the Dropdown.
I am trying to figure out how to use Scala Futures in a recursive manner. The use case I have is to compare the output of a resource ( ResourceOne) with another resource (ResourceTwo) output, if there are any discrepancies between them in the…
Stream.take takes an int as a parameter. I want to define a take that takes a long instead- is this possible without using takeWhile to manage a counter?
For a long listing of cases which return a value within a limited domain, how to reduce the otherwise growing number of case declarations ? For instance consider
"abc" match {
case "a" => 1
case "ab" => 1
case "aw" => 2
case "hs" => 2
…
This feels like a dumb question, but here goes:
Consider the following to update a value of Int in a Map with a var of Int
var score: Int = _
val data = Map((
("things", "stuff") -> 0),
(("uwot", "stuff") -> 0),
(("isee", "stuff") ->…
I'm unable to get the top word in Array of int and Strings .
See the below Array and required output:
Consider n is an RDD and suggest me the Required functions for the getting output .
scala> n.take(10)
res3: Array[(Int, String)] = Array((4,Hi how…
I have a simple class which extends IndexedSeq[MyType]
class MyClass(someName: String, values: Iterable[MyType]) extends IndexedSeq[MyType] {
val name = someName
val rows = values.toVector
....
}
This works fine, allowing me to call all the…