Data dodania Pytanie
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
2017-02-23 19:02 compile error with implicit class method named "clone" »
I get an unexpected compilation error (in scala 2.11.8) when attempting to make an implicit class with a method named clone. The following simplified...
(2) odpowiedzi
2017-02-23 16:02 Why is it possible to instantiate multiple traits in Scala, but not a single one? »
Let's say we have two traits: trait Trait1 trait Trait2 If I try something like val single = new Trait1 I get an error error: trait Trait1 is abstr...
(1) odpowiedzi
2017-02-23 04:02 Summing "Large" Nat's »
Given: scala> import shapeless.nat. _0 _10 _12 _14 _16 _18 _2 _21 _3 _5 _7 _9 natOps _1 _11 _13 _15 ...
(2) odpowiedzi
2017-02-22 17:02 RoundingMode.HALF_UP difference in scala and Java »
In scala, I am trying to round up the following number to the 3 decimal precision using HALF_UP rounding mode. 8409.3555 Unfortunately scala is retu...
(2) odpowiedzi
2017-02-22 15:02 scala Seq sortWith or sortBy with NaNs »
I've encountered some very strange sorting behaviour in scala (2.11.8 and 2.12.1) for Seq[(Long, Double)]. I am probably misunderstanding something fu...
(1) odpowiedzi
2017-02-22 14:02 Zipwith Product Implementation with Shapeless? »
Given: // Given an HList of size N, provide evidence of the sum of HList // multiplied by _3 (length) :: _2 (length) :: _1 (length) :: HNil // Exampl...
(1) odpowiedzi
2017-02-21 15:02 Is it possible to force early evaluation of a curried function? »
Consider a function that returns another function: def prepareFunction(args: List[Any]): String => Unit = { println(s"Slow processing of $args.....
(2) odpowiedzi
2017-02-21 05:02 Encoding Scala None to JSON value using circe »
Suppose I have the following case classes that need to be serialized as JSON objects using circe: @JsonCodec case class A(a1: String, a2: Option[Stri...
(1) odpowiedzi
2017-02-21 02:02 How to persist a scala list to mongodb using spark »
so I have a spark code that fetch some documents from mongodb, does some transformation and tries to store it back to mongodb. The problem happens wh...
(1) odpowiedzi
2017-02-20 22:02 Friend access in Scala »
Consider a function f defined in package p1 a package p2 which does not contain p1 a package p3 which does not contain p2 or p1 nor it is containe...
(1) odpowiedzi
2017-02-20 19:02 EMR Spark Fails to Save Dataframe to S3 »
I am using the RunJobFlow command to spin up a Spark EMR cluster. This command sets the JobFlowRole to an IAM Role which has the policies AmazonElasti...
(2) odpowiedzi
2017-02-20 18:02 Currying syntax in scala »
The syntax of currying in scala is for example def f(x: Int, b: Int) = x + y is def f(x: Int)(b: Int) = x + y And currying for sum to sum for giv...
(2) odpowiedzi
2017-02-19 22:02 How to apply javascript to html simulating a browser »
I've already searched on the Internet how to "create" a simple headless browser, because I was interested to know how does a Browser works internally....
(1) odpowiedzi
2017-02-19 18:02 Scala: For loop that matches ints in a List »
New to Scala. I'm iterating a for loop 100 times. 10 times I want condition 'a' to be met and 90 times condition 'b'. However I want the 10 a's to occ...
(2) odpowiedzi
2017-02-19 09:02 Scala chaining functions with andThen type mismatch »
I have a bunch of functions that clean text and splits them into words. Minimal example: val txt = "Mary had a @little \nlamb" val stopwords = Seq("a...
(1) odpowiedzi
2017-02-18 22:02 Generalizing DivisibleBy in type-level programming with Scala »
I'm trying to generalize a divisible-by relation in Scala using type level programming. This is my Nat number definitions: trait Nat { type plus[N&...
(1) odpowiedzi
2017-02-18 21:02 Scala String toInt - Int does not take parameters »
So I'm learning Scala and I came across this finicky issue... If we have a String and want to convert it to an Int, all examples that I've found onli...
(1) odpowiedzi
2017-02-18 13:02 How to use Apply for Function Application »
I have the following validation logic: def one(a : String) : Validation[String, Int] = if (a == "one") { Success(1) } else { Fa...
(1) odpowiedzi
2017-02-18 02:02 Reconstructing object tree from joined query »
Let's assume I have following DB model (not a real case so please forgive me the utter silliness of this example): I want to fetch joined result fr...
(0) odpowiedzi
2017-02-17 21:02 Functional way to find a pair of integers, which sum to X, in a sorted array »
This is a follow-up to my previous question. Suppose I want to find a pair of integers, which sum to a given number x, in a given sorted array. The we...
(4) odpowiedzi
2017-02-17 15:02 Circe: decode multi-level ADT efficiently »
I want to decode the following ADT with Circe: sealed trait PaymentType object PaymentType extends EnumEncoder[PaymentType] { case object DebitCard...
(1) odpowiedzi
2017-02-17 13:02 Matching against Value Classes in Akka »
I've created the Value Class final class Feature(val value: Vector[Double]) extends AnyVal To match against that class in scala: val d = new Featu...
(1) odpowiedzi
2017-02-17 06:02 Which Monad Transformer to use? »
I am trying to write the validate function below so that the validation stops after the first error encountered. The return type of three is different...
(2) odpowiedzi
2017-02-16 14:02 Scala way of applying function to list and getting highest result with input »
best_acc = 0 for split in split_candidates: acc = self.get_split_score(t_series_distances, split) if acc > best_acc: best_acc = acc...
(1) odpowiedzi
2017-02-16 12:02 How to traverse array from both left to right and from right to left? »
Suppose I have an imperative algorithm that keeps two indices left and right and moves them from left to right and from right to left var left = 0 v...
(3) odpowiedzi
2017-02-16 10:02 Pattern matching java.lang.Long »
I'm confused with scala pattern matching behaviour, see code below: import java.util.concurrent.atomic.AtomicLong object LongPatternMatching { de...
(2) odpowiedzi
2017-02-15 23:02 Scala compilation time report »
I've got a project that isn't a crazy number of lines of code, but its compilation time is really long on a clean compile. I have the feeling there ar...
(0) odpowiedzi
2017-02-15 11:02 Obtaining the full info about fields of the case class in Scala »
Consider the following class and method: case class User(id: Long, name: String) { private var foo = "Foo" // shouldn't be printed val bar = "bar...
(1) odpowiedzi