I am trying to pass a list of integers in the IN clause of a SQL Server JDBC query using Slick API for scala. The val stockIdsOfInterest is a list of integers that I want to pass in the IN clause. Here is my query:
val stockIdsOfInterest = …
I am wrapping a mutable parallel map in Scala and would like to remove and return a single value from the map. Current implementation is as follows...
class MyContainer[O] {
def remove(uuid: UUID): Option[O] = backingStore.get(uuid) match {
…
I tried to use the GraphStream library to find the shortest path between 2 nodes in a graph. At the end I'm able to print the edges of the path (it.foreach(println)) but I can't access one element at the time. This is the code:
import…
I'm writing a small exercise app that calculates number of unique letters (incl Unicode) in a seq of strings, and I'm using aggregate for it, as I try to run in parallel
here's my code:
class Frequency(seq: Seq[String]) {
type FreqMap = Map[Char,…
In Scala collections (e.g. 2.11 or 2.12), where can I find the code that gets executed when an Array is mapped?
i.e.
val a = Array(1,2,3)
val b = a.map(_ * 5) // <--- here
Looking to compare field by field of rdds by key and trying to populate the unmatched array fields but unable to use for loop.
below code wherein for loop is commented is working for 1st field check but I wanted to use for loop to cover all fields…
A newbie Scala question .
I'm trying to implement a function that receive two Lists ,find a common item , than make manipulation and create a new list
I have a case class
case class weightedFruits(fruits: Set[String], weight: Double)
and two…
I have a JSON String ,
val name : String = "["Client_2","tClient_1","Client_NB"]"
I have converted the Json String to JSValue as below using play
val json: JsValue = Json.parse(cells)
Output of json :…
The job is to convert the values from the src array and write the new values to the dst array.
When I create ForkJoinTasks in a while loop
val height: Int = 4;
val numTasks: Int = 2;
var tasks =…
I am trying my hand at a bit of generic programming with Scala and am trying to figure out how to create an instance of a class of type CC as described in the code below. I have defined the following abstract trait...
/** Trait defining the…
In a previous SO post I asked about an idiomatic way to make a container class wrapping an immutable collection thread-safe. Answers that I received all involved using various flavors of read/write locks or synchronization which is not what I…
Using Spark, I have a data structure of type val rdd = RDD[(x: Int, y:Int), cov:Double] in Scala, where each element of the RDD represents an element of a matrix with x representing the row, y representing the column and cov representing the value…
I have a JSON string, say:
val json = JSONObject(Map("a" -> 1)).toString()
I want to convert this json to map again. I tried:
val map = json.toMap[String, Int]
This gives me the following error:
Error:(46, 25) Cannot prove that Char <:< (String,…
I've got list of pairs:
List(('a',3),('b',3),('a',1))
and I would like to transform it by grouping by _1 and summing _2. The result should be like
Map('a'->4, 'b' -> 3)
I very new to Scala so please be kind :)