Questions tagged [scala-collections]

Collection library for Scala Programming Language

Related Tags:

1639 questions
0
votes
1 answer

create two immutable data structure in one go using scala for comprehension or any other feature

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.…
HKumar
  • 655
  • 1
  • 8
  • 18
0
votes
3 answers

Partitioning a List into more than two partitions

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…
Adam Davies
  • 2,742
  • 4
  • 33
  • 52
0
votes
1 answer

Scala List method `::` vs `+:`

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?
ttt
  • 3,934
  • 8
  • 46
  • 85
0
votes
1 answer

error trying to get errors with scala Try function

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 =…
nick shmick
  • 905
  • 1
  • 9
  • 25
0
votes
1 answer

What is an idiomatic Scala way to do batch processing with exceptions

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…
raisercostin
  • 8,777
  • 5
  • 67
  • 76
0
votes
2 answers

Omit input data of map function in Scala

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,…
Shen Li
  • 411
  • 3
  • 14
0
votes
1 answer

Scalaj-Http: Using HttpRequest and getting back HttpResponse[string] - How can I access individual JSON elements of Respnse.Body?

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, …
Sahil Sharma
  • 3,847
  • 6
  • 48
  • 98
0
votes
2 answers

Converting from Java List to Scala mutable Buffer

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…
0
votes
0 answers

Select a value from Drop Down dev Tag

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.
lahiruW
  • 39
  • 1
  • 8
0
votes
1 answer

Scala: Recursive use of Future

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…
mzafer
  • 791
  • 7
  • 21
0
votes
1 answer

Can I do a lazy take with a long parameter?

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?
lsankar4033
  • 509
  • 3
  • 14
0
votes
3 answers

Scala large listing of cases in pattern matching

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 …
elm
  • 20,117
  • 14
  • 67
  • 113
0
votes
1 answer

Scala Map: is it possible to update a value of Int with a var of Int?

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") ->…
plamb
  • 5,636
  • 1
  • 18
  • 31
0
votes
1 answer

scala Spark get the top words in each row of Array

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…
MapReddy Usthili
  • 288
  • 1
  • 7
  • 23
0
votes
2 answers

Creating instance type after filter

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…
Martin Cooper
  • 439
  • 1
  • 4
  • 11
1 2 3
99
100