Data dodania Pytanie
2017-03-18 19:03 Why type any is returned? »
I have following ADT sealed trait Option[+A] { def map[B](f: A => B): Option[B] = this match { case None => None case Some(a) => ...
(1) odpowiedzi
2017-03-18 18:03 Scala primary constructors and the fields/properties they generate »
New to Scala and no matter how many articles/tutorials I read (like these | three | ones) I can't seem to wrap my brain around how constructors work. ...
(2) odpowiedzi
2017-03-18 08:03 Scala: How to merge lists by the first element of the tuple »
Let say I have a list: [(A, a), (A, b), (A, c), (B, a), (B, d)] How do I make that list into: [(A, [a,b,c]), (B, [a,d])] with a single fun...
(2) odpowiedzi
2017-03-17 19:03 Stream stdout from scala Process »
I am using scala Process to kick off a python program and using ProcessLogger to capture the stdout from the python program. I see that the print stat...
(1) odpowiedzi
2017-03-17 17:03 Can the subflows of groupBy depend on the keys they were generated from ? »
I have a flow with data associated to users. I also have a state for each user, that I can get asynchronously from DB. I want to separate my flow wit...
(0) odpowiedzi
2017-03-17 16:03 Permutations with for comprehensons »
So I have a bit of a problem figuring out how to generate permutations with Scala for comprehensions. The problem is that I want to have function that...
(1) odpowiedzi
2017-03-17 03:03 Why does Scala sometimes ignore types that are clearly defined? »
so here's the problem I keep running into various situations with Scala - it seemingly ignores the implied type, even when the situation is clear. Gra...
(1) odpowiedzi
2017-03-16 19:03 Scala Count Variable »
I've been looking for a way to use a count to iterate through my List but I haven't found a way, I tried to use var count = 0 to no avail. Here is my...
(2) odpowiedzi
2017-03-16 15:03 React Component not rending in Play app »
I have a Play/scala/sbt project with following React component saved at app/assets/javascripts/nav.jsx: class Nav extends React.Component { const...
(1) odpowiedzi
2017-03-16 13:03 How to use Spark broadcasting to avoid serialization error with machine learning models? »
I need to use a previously trained machine learning model in order to make predictions. However, I need to make predictions inside foreachRDD, because...
(0) odpowiedzi
2017-03-15 14:03 Why is casting from long to date not allowed in spark? »
In Spark you can cast a LongType without issues to TimestampType. And after that there are no issues casting a TimestampType to a DateType. The flow ...
(0) odpowiedzi
2017-03-15 13:03 Testing Recursive Data Structure »
ScalaCheck: The Definitive Guide explains how to create generators for recursive data structures. First, it defines the data structure: trait Tree[T...
(1) odpowiedzi
2017-03-15 01:03 scala inline function - "ar.reduce((x,y) => x)" works but "ar.reduce{case(x,y) => x}" doesnt »
given the following input: scala> val as = List(Array(1,2,3), Array(10,20,30), Array(100,200,300)) as: List[Array[Int]] = List(Array(1, 2, 3), Arr...
(2) odpowiedzi
2017-03-15 00:03 When is case syntactically significant? »
A/a case, not case case. Apparently case a matches anything and binds it to the name a, while case A looks for an A variable and matches anything == ...
(1) odpowiedzi
2017-03-14 19:03 Errors accumulation with Monoid »
Suppose I have a list of functions E => Either[Exception, Unit] to invoke upon event E and accumulate the errors to return Either[List[Exception], ...
(1) odpowiedzi
2017-03-14 11:03 Behavior in scalaz not understood »
A question from a ScalaZ neophite here. I don't quite understand how the: 1.some or the disjunction related: "Success!".right work. I am not ab...
(1) odpowiedzi
2017-03-14 11:03 Application of understanding monad in real world »
I'm studying functional programming in Scala and I learnt term monad. In short monad is: trait M[A] { def flatMap[B](f: A => M[B]): M[B] } def ...
(2) odpowiedzi
2017-03-14 07:03 Scala implicit conversions and mkNumericOps with value classes »
I am trying to add numeric operations to a value class that I have defined called Quantity. Code that I am using this is as follows... import scala....
(1) odpowiedzi
2017-03-13 20:03 Default type parameter in inheritence »
Say I have the following classes: class A[T] { ... } abstract class B[T1,T2](t: T1)(implicit ev: A[T2]) { ... } On some instances, when I inherit...
(1) odpowiedzi
2017-03-13 17:03 Why can't a Promise be covariant »
In Scala, a Future is defined to be covariant whereas a Promise is invariant. It is said that a Promise can almost be made contravariant (https://issu...
(2) odpowiedzi
2017-03-13 08:03 Refactoring an OOP "decorator" to Free monad structure(s) »
I have a bit of “legacy” Scala code (Java-like), which does a bit of data access. There’s a decorator which tracks usage of the DAO methods (col...
(2) odpowiedzi
2017-03-12 18:03 How to use scala.sys.process with scala.js »
I have imported scala.sys.process._ into my scala.js project. That alone doesn't cause any problems, but if I add a simple command such as println("ls...
(1) odpowiedzi
2017-03-12 15:03 Remove event Listener in scala.js »
I have a list of buttons with an event listener added to them: import org.scalajs.dom.MouseEvent import org.scalajs.dom.html.Button import org.scal...
(1) odpowiedzi
2017-03-12 13:03 Getting Scala enum instances »
I have the following Scala enum which I designed after reading this answer: object RunMode extends Enumeration { val CLIENT_MODE = Value("CLIENT_...
(2) odpowiedzi
2017-03-11 20:03 How to map with scala constructor »
I'm working on the functional programming in Scala Coursera course; and I'm working on the exercise about Huffman coding trees. Here's the code repre...
(1) odpowiedzi
2017-03-11 19:03 How to convert a List to RDD with scala and spark »
I'm trying to generate an RDD from a List and another RDD using scala and spark. The idea is to take a list of values, and generate an index containin...
(2) odpowiedzi
2017-03-11 12:03 Functional Programming: is foldLeft is the parent method of all functional methods such as foldRight, map, filter »
I'm learning Scala and a new comer in Functional Programming world. I see that most of all methods such as foldRight, map, filter, reduce ... always c...
(3) odpowiedzi
2017-03-11 08:03 How to import play in scala repl »
How can I import play in Scala repl? scala> import play.api.libs.json._ <console>:11: error: not found: value play import play.api.li...
(3) odpowiedzi
2017-03-10 20:03 Scala Future not entering onComplete() »
I am trying to grab the value from a snippet of code that results in a Future, but when I run through the code, it turns out that it never enters the ...
(2) odpowiedzi
2017-03-10 17:03 How to force sbt to fetch everything it needs once? »
I'm working in a project in a very security concious place with no access via proxy to all the online repositories SBT usually requires. We'd like to ...
(1) odpowiedzi
2017-03-10 10:03 How to force DataFrame evaluation in Spark »
Sometimes (e.g. for testing and bechmarking) I want force the execution of the transformations defined on a DataFrame. AFAIK calling an action like co...
(2) odpowiedzi
2017-03-10 01:03 Cassandra Timeouts with No CPU Usage »
I am getting Cassandra timeouts using the Phantom-DSL with the Datastax Cassandra driver. However, Cassandra does not seem to be overloaded. Below is ...
(2) odpowiedzi
2017-03-09 22:03 Use an image from public folder »
I'm trying to set as background an image located at /public/images/my-image.jpg I've tried <body background="public/images/my-image.jpg"> an...
(3) odpowiedzi
2017-03-09 16:03 Stream Continually only reads for 1 minute »
Stream.continually returns empty String if in.readLine takes longer than 1 minute val f = SSLSocketFactory.getDefault.asInstanceOf[SSLSocketFactory] ...
(1) odpowiedzi
2017-03-09 12:03 Longest common suffix »
I I would like to find the longest common suffix of two strings in Scala. def longestSuffix(s1: String, s2: String) = { val it = (s1.reverseIterat...
(3) odpowiedzi