I've just been playing with Scala, and installed the Eclipse plugin as described at http://www.scala-lang.org/node/94, but after entering the "Hello World" test example and setting up the run configuration as described, I get the following error
Exception in thread "main" java.lang.NoSuchMethodError: main
For reference the code is
pa...
I have some Scala code that does something nifty with two different versions of a type-parameterized function. I have simplified this down a lot from my application but in the end my code full of calls of the form w(f[Int],f[Double]) where w() is my magic method. I would love to have a more magic method like z(f) = w(f[Int],f[Double])-...
An example:
val l = List(1,2,3)
val t = List(-1,-2,-3)
Can I do something like this?
for (i <- 0 to 10) yield (l(i)) yield (t(i))
Basically I want to yield multiple results for every iteration.
...
In response to a previous question on how to achieve a certain effect with Swing, I was directed to JDesktopPane and JInternalFrame. Unfortunately, scala.swing doesn't seem to have any wrapper for either class, so I'm left with extending it.
What do I have to know and do to make minimally usable wrappers for these classes, to be used wi...
I'm about to write a Scala command-line application that relies on a MySQL database. I've been looking around for ORMs, and am having trouble finding one that will work well.
The Lift ORM looks nice, but I'm not sure it can be decoupled from the entire Lift web framework. ActiveObjects also looks OK, but the author says that it may not ...
I'm familiar with using mock objects to help unit test my Java types, but find the inflexibility can lead to verbose and cumbersome test types and a lot of repetition.
I've looked at using Groovy for unit tests with moderate success. I'm interested in learning Scala for itself, but would also like some advice on using it for testing Jav...
Is it possible, in theory, to use the Scala Actor Framework to do a kind of asynchronous divide-and-conquer computation similarly to JDK 7's Fork-Join framework? If so, how could I express an FJ problem with the framework - for example, the tutorial mergesort concept? Code snipplets are welcome.
(I came to the idea based on a resource v...
I was reading this, http://www.scala-lang.org/node/105, and wondered when it was better to use Abstract Types e.g.
abstract class Buffer {
type T
val element: T
}
rather that generics, e.g.
abstract class Buffer[T] {
val element: T
}
...
This is probably a simple problem to the scala educated mind but I'm still a beginner ;)
I have a base actor who dispatches a task to multiple worker actors and replies it's result to a blocking external call via !?
a = new a
a.start
println(a !? "12345")
class a extends Actor {
def act = {
loop {
react {
case ms...
Suppose I have
val foo : Seq[Double] = ...
val bar : Seq[Double] = ...
and I wish to produce a seq where the baz(i) = foo(i) + bar(i). One way I can think of to do this is
val baz : Seq[Double] = (foo.toList zip bar.toList) map ((f: Double, b : Double) => f+b)
However, this feels both ugly and inefficient -- I have to convert both...
I am fairly new to to Scala and am still trying to develop a feel for which approaches are efficient and which might contain hidden performance costs.
If I define a (non-tail) recursive function which contains an inner function. Are multiple copies of the inner function's functional object instantiated for each recursive call?
For exam...
Coming from an academic background in mutli-agent systems (developed in Java using JADE) I have only been peripherally aware of the Actor concurrency paradigm. Now that I've started exploring Scala I couldn't help but be struck by the similarities between the Agent and Actor approaches.
I'm very tempted to use Scala's Actor library for...
I've just started playing around with Scala, and I just learned about how methods can be made right-associative (as opposed to the more traditional left-associativity common in imperative object-oriented languages).
At first, when I saw example code to cons a list in Scala, I had noticed that every example always had the List on the rig...
I would like to know what the best Scala imitation of Groovy's safe-dereference operator (?.), or at least some close alternatives are?
I've discussed it breifly on Daniel Spiewak's blog, but would like to open it up to StackOverFlow...
For the sake of everyone's time, here is Daniel's initial response, my counter, and his 2nd response...
Python supports an elegant syntax for "chained comparisons", for example:
0 <= n < 256
meaning,
0 <= n and n < 256
Knowing that it's a fairly flexible language syntactically, is it possible to emulate this feature in Scala?
...
How do I get an instance of Class in Scala? In Java, I can do this:
Class<String> stringClass = String.class;
What would be the equivalent in Scala?
...
I have been interested in programming all my life and for the past 6 years I have worked almost exclusively with Java. I just finished with my University studies and have a job as a Java developer for a company.
All these years programming has been a hobby and a favorite past time, but this had a slightly negative effect in the sense th...
Is it possible to do something similar to LINQ to Events in Scala? Is this similar to the new Traversable trait in Scala 2.8?
...
i try to copying the examples in wiki
http://wiki.liftweb.net/index.php/Hello_Darwin
in the example of HelloForm2.scala
"submit" -> submit(?("Send"), () => {println("value:" + who + " :: " + param("whoField"))}),
it always print "value:Full(hogehoge) :: Empty" even if i set the who as "object who extends RequestVar(Full("world"))".
...
Java code:
import javax.swing.Timer;
class Main {
public static void main(String args[]) {
MyListener myListener = new MyListener();
Timer timer = new Timer(1000, myListener);
timer.start();
while(timer.isRunning()) {
System.out.print(".");
}
}
}
Scala code:
import java.awt.event.A...