Data dodania Pytanie
2017-03-07 12:03 How to manage partial matching with regex? »
I have a regex like this: val myregex = "This is a (.*) text for (.*) and other thing like .*".r If I run : > val myregex(a,b) = "This is a t...
(2) odpowiedzi
2017-03-06 15:03 How to constrain argument by type member of type parameter in scala? »
The function reduceTo gets a type parameter indicating the kind of time series that should be returned, but the function splitInto requires a Period v...
(1) odpowiedzi
2017-03-06 08:03 scala: How to know the program have unhandled exceptions before running? »
this is a test program: object Test { def main(args: Array[String]): Unit = { // there is an unhandled exception in here, I expect progr...
(2) odpowiedzi
2017-03-06 02:03 How to query using column names that include "$"? »
In Spark SQL, I can use val spark = SparkSession .builder() .appName("SparkSessionZipsExample") .master("local") .config("sp...
(1) odpowiedzi
2017-03-05 16:03 scala pattern matching on (Try,Try) »
I have the the following Tuple - (t1,t2) :(Try,Try) I want to check if both succeeded or if one of them failed, but avoid code duplication. Something...
(4) odpowiedzi
2017-03-05 15:03 Why do scala REPL and Ammonite behave differently in this point and which behaviour is correct? »
The Scala expression .3.+(5) evaluates to 5.3 as a result in Ammonite-REPL, as I expected. In the Scala REPL, though, it yields a syntax error, pri...
(2) odpowiedzi
2017-03-05 08:03 akka stream: how to reconnect TCP after disconnected »
I have a simple balancer that dispatch jobs to several external worker processes via TCP: val sinkBalance = Sink.fromGraph(GraphDSL.create() { implic...
(0) odpowiedzi
2017-03-04 22:03 SBT finding subtype in Sources »
Is there any way to find classes/objects that extend a certain class in sbt in the sources? I played around with https://github.com/ruippeixotog/sbt-...
(0) odpowiedzi
2017-03-04 20:03 Scala Monoid[Map[A,B]] »
I'm reading a book with the following: sealed trait Currency case object USD extends Currency ... other currency types case class Money(m: Map[Curre...
(1) odpowiedzi
2017-03-04 19:03 How to have SBT re-run only failed tests »
Is there a way to have SBT re-run only the tests that have failed in the last run of the test suite? For example, if I run sbt test and 3 out of the 2...
(1) odpowiedzi
2017-03-03 18:03 Variance when T needs to be in covariant and contravariant position »
Here is my problem, I have a typeclass defined like this : trait Alterer[T] { def alter(t: T): T } object Alterer { implicit val stringPrinter =...
(1) odpowiedzi
2017-03-03 09:03 what's the difference between Array and Buffer when using scala? »
when I work on some task using scala , I wrote some code as follows: object He { def main(args: Array[String]): Unit = { var myMatrix = Array.o...
(1) odpowiedzi
2017-03-03 00:03 Scala implicit for Option containing Map »
I am trying to write the following implicit: implicit class ExtractOrElse[K, V](o: Option[Map[K, V]]) { def extractOrElse(key: K)(f: => V): V = ...
(2) odpowiedzi
2017-03-02 11:03 Convert List of Object to Map with duplicate key »
I have a class that looks like this: case class Person(id : String, name : String, refId : String) {} And I have a list of Person. I want to have ...
(1) odpowiedzi
2017-03-02 02:03 Why can't I match on a Stream? »
Specifically: scala> def f(n: Seq[Any]) = n match { case Nil => "Empty" case h :: t => "Non-empty" } f: (n: Seq[Any])String sc...
(2) odpowiedzi
2017-03-02 00:03 Play JsPath writes for Infinite Double »
I am trying to implement a function writing Doubles that might have a value of Infinity (which does not exist in JSON). Here are some examples of w...
(1) odpowiedzi
2017-03-01 22:03 why can't I extract a tuple from Either projection inside for comprehension using pattern matching? »
Why does this work: val somePair: Option[(String,String)] = Some(("John", "Doe")) (for { pair <- somePair.toRight("Hello unknown!").right } yiel...
(1) odpowiedzi
2017-03-01 21:03 Combining two Option[List[String]] in Scala »
I have two Options val opt1 = Some(List("Sal", "Salil")) val opt2 = Some(List("Sal2", "Salil2")) Either opt1 or opt2 could be None. If either one i...
(3) odpowiedzi
2017-03-01 14:03 Scala traits,this and that serve for what? »
I am learning SCALA,I do not understand this example Understanding Scala Ordered[ ] trait to compare reference class Example(var n: Int) extends Ord...
(1) odpowiedzi
2017-02-28 19:02 Is foldRight equivalent to foldLeft given a noncommutative associative operation? »
In a online course it was stated that foldLeft and foldRight are equivalent for operators that are associative and commutative. One of the students i...
(4) odpowiedzi
2017-02-28 09:02 Finding pairs of sets so that their union has a specific size »
I have a variable like follow: var L_s = collection.mutable.Set[collection.mutable.Set[Int]]() and I want to find the union of sets of different s...
(3) odpowiedzi
2017-02-28 05:02 Why memory sink writes nothing in append mode? »
I used spark's structured streaming to stream messages from kafka. The data was then aggregated, and wrote to a memory sink with append mode. However,...
(1) odpowiedzi
2017-02-27 21:02 How to compose typeclasses in Scala? »
I have code that looks like this: /** * A divisor that operates on real numbers. */ case class RealDivisor(divisor: Long) extends Divisor[Doubl...
(1) odpowiedzi
2017-02-27 18:02 Equivalent of flatten method in Scala 2.11 to handle nested futures »
In scala 2.12 I can write the following code import scala.concurrent._ import scala.concurrent.ExecutionContext.Implicits.global val x = Future(Futur...
(1) odpowiedzi
2017-02-27 10:02 Akka HTTP Connection Pool Hangs After Couple of Hours »
I have an HTTP Connection Pool that hangs after a couple of hours of running: private def createHttpPool(host: String): SourceQueue[(HttpRequest, Pr...
(1) odpowiedzi
2017-02-26 23:02 Type lambda that returns a type lambda in Scala »
I want to have a type lambda in Scala that returns a type lambda instead of a type. def f[A](implicit ev1: Eq[A], ev2: ClassTag[A]) I want to combi...
(1) odpowiedzi
2017-02-26 14:02 Why isn't a member of type Option[String] being serialized? »
I have a dummy class Foo which has three members: import play.api.libs.json.Json case class Foo(id: String, fooType: FooType, nextId: Option[String]...
(1) odpowiedzi
2017-02-26 06:02 Joining two datasets spark scala »
I have two csv files (datasets) file1 and file2. File1 consists of following columns: Orders | Requests | Book1 | Book2 Varchar| Integer | Integer...
(1) odpowiedzi
2017-02-25 18:02 Introducing termination as a precondition in Leon/Stainless »
I'm trying to proof that the evaluation of the untyped lambda calculus according to the following function: def eval(t: Term): Option[Term] = t mat...
(1) odpowiedzi
2017-02-25 14:02 ScalaCheck can not cast boolean to Prop instance »
I have the following property: import org.scalacheck.Prop.propBoolean def elementsAreReversed(list: List[Int], reversed: List[Int]): Boolean = if ...
(1) odpowiedzi
2017-02-25 08:02 How to send a collection to spark nodes only once? »
Consider the simple code from this previous question: Large task size for simplest program import org.apache.spark.{SparkContext, SparkConf} object ...
(2) odpowiedzi
2017-02-24 17:02 akka-http: send element to akka sink from http route »
How can I send elements/messages to an Akka Sink from an Akka HTTP route? My HTTP route still needs to return a normal HTTP response. I imagine this ...
(2) odpowiedzi
2017-02-24 11:02 Resolving types in F-bounded polymorphism »
I have these models: trait Vehicle[T <: Vehicle[T]] { def update(): T } class Car extends Vehicle[Car] { def update() = new Car() } class Bus exte...
(2) odpowiedzi
2017-02-24 10:02 Scala: common practice for writting foldLeft »
In functional programmming, there are two important methods named foldLeft and foldRight. Here is the implementation of foldRight sealed trait List[+...
(2) odpowiedzi
2017-02-24 08:02 Scala way to convert Any number to Double »
I need to do some raw data parsing and I am forced to work with Any type. If the data I read is in any numeric format (Int/Double/Long/...) I need to ...
(3) odpowiedzi