I am starting to I am learning scala, and trying to build some simple applications to test drive the language more.
I am looking for non-intrusive framework/container for mid tier applications (not the web framework). Originally, I was about to start off with spring since I am very familiar with it. However, given that scala provides ...
I would like to create a storage for the following type:
List(List(2.3,1.1),List(2.2, 1))
But if I do the following:
var y = List(List (1.0, 2.2), List(2, 1.1, -2.1))
then it creates as List[AnyVal] and gives me error if I try to perform math operation:
y(0)(0) * 2 // Error - value '2' is not a member of AnyVal
...
I have a dynamically changing input reading from a file. The numbers are either Int or Double. Why does Scala prints .0 after every Double numbers? Is there a way for Scala to print it the same way it reads it
Example:
var x:Double = 1
println (x) // This prints '1.0', I want it to print '1'
x = 1.0 // This ...
Hi,
I am trying to create a generic class with generic type being subclass of Numeric (to ensure that I am dealing with numbers.)
and I tried "class NuVector[T<:Numeric[T])" as class def and it compiling fine.
Now I want to add PartiallyOrdered[T] to it. so I did the following:
class NuVector[T<:Numeric[T]) extends PartiallyOrdered[T]...
I've recently started learning Scala and was disappointed (but not surprised) that their generics are also implemented via type erasure.
My question is, is it possible for Scala to have reified generics, or would the JVM need to be changed in some way? If the JVM does need to be changed, what exactly would need to be changed?
...
A friend gave me this code snippet in Closure
(defn sum [coll acc] (if (empty? coll) acc (recur (rest coll) (+ (first coll) acc))))
(time (sum (range 1 9999999) 0))
and asked me how does it fare against a similar Scala implementation.
The Scala code I've written looks like this:
def from(n: Int): Stream[Int] = Stream.cons(n, from(n+...
Given that it's impossible to see into the future, what factors related to Clojure, Scala or Haskell are likely to determine whether one of them catches on?
Are there cultural or economic issues that could give one of these languages an advantage over the others?
Or are none of these languages likely to gain traction because of their c...
I'm considering using Actors in a system to wrap some storage (could be a database, could be an in-memory collection). The reason I want to do this is because I don't want calls to the store to be blocking from the code that's calling it and I intend to push a high volume of messages through.
Could an actor's inbound message queue handl...
I'm would like to use Scala to persist data to a relational database, so what I am looking for are examples of CRUD operations using Scala.
I would like to code on a lower level of abstraction than an ORM like Hibernate/Toplink (read:JDBC), but between us, I would like to see examples of all types.
Thanks folks.
...
How to make a standalone lift application? Which tools/libraries to use? How does the performance compare to using lift application as a war in some application server?
...
Having seen the answers coming out of questions like this one involving horror shows like trying to catch the NPE and dredge the mangled name out of the stack trace, I am asking this question so I can answer it.
Comments or further improvements welcome.
...
I was wondering if there was a way to execute very simple tasks on another thread in scala that does not have a lot of overhead?
Basically I would like to make a global 'executor' that can handle executing an arbitrary number of tasks. I can then use the executor to build up additional constructs.
Additionally it would be nice if block...
I'm using Netbeans to write Scala and Java.
Netbeans generated a .jar file for the Scala project. I tried importing that file in the Java project. But I couldn't import any class from that .jar file into my Java project.
I also tried importing scala-library.jar to the java project, and could import classes from that jar.
I want to wri...
Scala's Enumeration class and the Enumeration.Val readResolve method do not appear to work as they should do (possibly related to this entry in Scala trac). Here is a program provided by *Steve Bendiola" to illustrate the problem:
@serializable
object InvestmentType extends Enumeration {
val Debt = Value("DEBT")
val Future = Value("...
This question is about the way that Scala does pattern matching and recursion with lists and the performance thereof.
If I have a function that recurses over a list and I do it with matching on a cons, for example something like:
def myFunction(xs) = xs match {
case Nil => Nil
case x :: xs => «something» myFunction(xs)
}
in Hask...
I have the following code. If I comment the call to "foo()" inside the actor's body, the code works fine. But if "foo()" is activated... my code freezes!
Anyone kwnows why?
import scala.actors.Actor._
object Main extends Application{
def foo() = {
println("I'm on foo")
}
def testActor() = {
val target = self
...
What is a good way of creating non-blocking methods in Scala? One way I can think of is to create a thread/actor and the method just send a message to the thread and returns. Is there a better way of creating a non-blocking method?
...
What was your methodology to learn Scala? (exercises? small project? library? manual?)
What surprises have you encountered when you have been learning Scala?
Both subjectively positive and negative.
Please state also what is your background i.e. primary language of your choice.
Edit: Please try to state your experience, not opinions.
...
I'm porting over the interpreter for a domain specific language I created from Scala to Python. In the process I tried to find a way that way pythonic to emulate the case class feature of Scala that I used extensively. In the end I resorted to using isinstance, but was left feeling that I was perhaps missing something.
Articles such as ...
What would make you to switch to Scala ?
If you are negative on the switching to Scala, please state the reason as well (or upvote).
As with all StackOverflow Poll type Q&As, please make certain your answer is NOT listed already before adding a new answer
If it already exists, vote that one up so we see what the most popular answe...