I want an infinite queue that is backed by an infinite stream in Scala. This feels simple enough but I just can't find how to do this.
I.e.
Stream.from(0).toQueue // Except that there is no method "toQueue"
I want to get first argument for main method that is optional, something like this:
val all = args(0) == "all"
However, this would fail with exception if no argument is provided.
Is there any one-liner simple method to set all to false when args[0]…
In Scala, suppose I would like a class that is just like List[String] except for a few methods, for example toString.
What I have now is
case class FQN(val names : List[String]) extends LinearSeq[String] {
def this( params : String* )…
I have the following sample code :
package models
import java.util.concurrent.atomic.AtomicInteger
import scala.collection.mutable.ArrayBuffer
case class Task(id: Int, label: String)
object Task {
private val buffer = new ArrayBuffer[Task]
…
I'm still pretty new to Scala. I'm having trouble trying to append two Sequences together because the compiler is complaining about the type of the Seq. I would like to start with a Seq[String] var and replace it with the addition of two…
I need to count occurrences of element in list.
List looks like this: List[(String, String, Int)] - list of (String, String, Int) tuples.
Example:
List(("Gregor", "Math", 6), ("Mark", "Math", 33),
("Gregor", "IT", 44), ("Jane", "Math", 3),
…
I have two lists
val list1 = List((List("AAA"),"B1","C1"),(List("BBB"),"B2","C2"))
val list2 = List(("AAA",List("a","b","c")),("BBB",List("c","d","e")))
I want to match first element from list2 with first element of list1 and get combined list.
I…
I have a string with with multiple length and breadth in the format length x breadth separated by commas like
300x250, 720x220, 560x80
I will like to convert this into two separate arrays one containing only length and another only…
First List data as below
List(("A",66729122803169854198650092,"SD"),("B",14941578978240528153321786,"HD"),("C",14941578978240528153321786,"PD"))
and second list contains data as below…
I plan to populate an immutable HashMap inside a scala class instance using a builder, then expose the hashMap with a method calling result() on the builder.
Is this call very cheap or is it worth saving this result in a member field for faster…
If I have
val incomingIds : List[Int] = ....
val existingIds : List[Int] = //this makes db calls and find existing records (only interested in returning ids)
Now next I want to compare incomingIds with existingIds in a following way
say I have
val…
Im trying to add items to a ListBuffer (or any other structure ?)
basically i'm trying to create a list of PostMD objects by using this method.
def getData(url: String, userID: String): ListBuffer[PostMD] = {
val chunk: JsValue =…