Hello,
in liftbook, there's an example of creating of a Req instance by using apply :
case Req(List("api", "expense", eid), "", GetRequest) =>
() => showExpense(eid)
but when I look into api documentation, there are two apply() methods, but I don't know which one and how is ran in this example.
Also, is there a way, how to include /a...
I start two remote actors on one host which just echo whatever is sent to them. I then create another actor which sends some number of messages (using !! ) to both actors and keep a List of Future objects holding the replies from these actors. Then I loop over this List fetching the result of each Future. The problem is that most of the ...
I've seen benchmarks of Actor model implementations done in terms of their actors. For example, Akka actors are very lightweight (600 bytes per actor) and millions of them can be created. However, I've never seen a benchmark done in terms of message-passing throughput.
For example, given some number of actors, how many messages can pass...
Can anyone recommend a good book on Scala programming as an introduction?
...
In Scala, for many (all?) types of collections you can create views.
What exactly is a view and for which purposes are views useful?
...
I'd like to have a Scala functions that returns the reference to another function, is that possible?
...
Say you define the following:
class Person(name: String, age: Int) {
def toXml =
<person>
<name>{ name }</name>
<age>{ age }</age>
</person>
}
val Persons = List(new Person("John", 34), new Person("Bob", 45))
Then generate some XML and save it to a file:
val personsXml =
<persons>
...
Behind the scenes, how is a mailbox (an actor's message queue) implemented in Scala Actors?
I thought it was MessageQueue, but it's been deprecated with the note that "this class is going to be removed in a future release". It looks like it might be in Channel, but I want the details of how the message queue itself is implemented.
...
Let's say I have this Hello.scala.
object HelloWorld {
def main(args: Array[String]) {
println("Hello, world!")
}
}
I could run 'scalac' to get HelloWorld.class and HelloWorld$.class.
I can run using 'scala -classpath . Hello'. But I can't run 'java -cp . Hello'.
Why is this? Isn't scala interoperable with Java?
Is there any...
Hi,
I wanted to add items dynamically into an array. But it seems Scala Arrays & Lists doesn't provide any methods for adding items dynamically due to the immutable nature.
So i decided to use List data type to make use of this :: method to achieve this. My code look like this
var outList = List(Nil)
val strArray = Array("ram","sam","...
I'm learning Scala with the aim of writing agent based simulations using actor concurrency. I currently know very little about OpenCL, and before I dive in can anyone tell me if it is likely to be appropriate/compatible with agent based simulations?
If so, then ScalaCL looks very attractive.
...
I needed to parse placeholders out of text like abc $$FOO$$ cba. I hacked to together something with Scala's parser combinators, but I'm not really happy with the solution.
In particular, I resorted to a zero-width matcher in the regular expression (?=(\$\$|\z)) to stop parsing the text and start parsing the placeholders. This sounds pe...
Hi!
I am trying to drop into the Scala interpreter in the middle of my Scala program.
I've seen this very interesting question but it does not seem to be working in Eclipse (3.5.2 + Scala plugin).
I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: scala/io/LowPriorityCodecImplicits
at scala.tools.n...
I'm trying to implement in Scala a generic data type parameterized on a type T, which should be Ordered[T]. Specifically, it's a persistent version of Sleator & Tarjan's skew heap priority queues. After adding lots of complicated type parameter declarations based on the explanation here and in Odersky-Spoon-Venners, I'm down to one compi...
Say you have a class Person, and create a collection class for it by extending e.g. ArrayBuffer:
class Persons extends ArrayBuffer[Person] {
// methods operation on the collection
}
Now, with ArrayBuffer, can create a collection with the apply() method on the companion object, e.g.:
ArrayBuffer(1, 2, 3)
You want to be able to do th...
Hi folks,
looks like when scala 2.8.0 is out, we can use nested @annotations in our persistence layers. But how? Can anyone please transform this from java to scala? Thanks.
@NamedQueries({
@NamedQuery(name = "findAll", query="select p from Person p"),
@NamedQuery(name = "findTheOne",
query="select p from Person p where...
Hi,
I need to have a collection of generic functions, but I can't get it done in the way I like.
I created a
List[(Any)=>Unit]
but as soon as I try to insert a function, for example a
String=>Unit
I get an error. How could I declare a generic function collection that does not consider parameter and return values types?
...
The ScalaDoc for the applet class is pretty thin on details on how you actually override the ui piece and add components. It says "Clients should implement the ui field. See the SimpleApplet demo for an example."
Where is this SimpleApplet demo?
Barring that, does anyone have some simple source code of using the Scala Applet class, ra...
Hello. I am new with Scala and I am writing a simple rss reader.
I have class Manager for managing feeds and content.
package lib
import scala.xml._
import java.net.URL
import net.liftweb.couchdb.{CouchDB, Database}
import dispatch.{Http, StatusCode}
/**
* @author smix
*
* Feeds manager
*/
object Manager {
var db = List[Database]...
I'm currently discovering scala and I was wondering if I could use traits with a factory.
I tried this :
abstract class Foo {
...
}
object Foo {
def apply() = new Bar
private class Bar extends Foo {
...
}
}
Foo() with MyTrait // Not working
I guess it's because with must be preceded by new.
So is there any way to do t...