scala

Would you recommend the book "Programming in Scala" for an experienced developer?

I would like to learn Scala. In the past, I have used Java and F# extensively. Would you recommend the book Programming in Scala for someone like me? I really liked the book Expert F#, and I was hoping that Programming in Scala would be in a similar vein, but the few chapters that are online are rather disappointing. Are there good res...

Is it possible to add a method to a built-in type in Scala?

I would like to add a method to a built-in type (say Double), so that I can use an infix operator. Is that possible? ...

Is there syntactic sugar for binding a value inside an anonymous function in Scala?

Instead of writing ((x: Double) => (((y: Double) => y*y))(x+x))(3) I would like to write something like ((x: Double) => let y=x+x in y*y)(3) Is there anything like this sort of syntactic sugar in Scala? ...

Building a scala app with maven (that has java source mixed in)

I have an application where I would like to have mixed Java and Scala source (actually its migrating a java app to scala - but a bit at a time). I can make this work in IDEs just fine, very nice. But I am not sure how to do this with maven - scalac can compile java and scala intertwined, but how to I set up maven for the module? Also...

lazy loading some config params, trying to come up with a pattern in Scala...

I want my client code to look somewhat like this: val config:Config = new MyConfig("c:/etc/myConfig.txt") println(config.param1) println(config.param2) println(config.param3) Which means that: The Config interface defines the config fields MyConfig is a Config implementation -- all the wiring needed is the in...

Non-numerical use cases for functional programming ?

I just finished reading a book on scala. What strikes me is that every single example in the whole book was numerical in some form or another. Like a lot of programmers, the only math I use is from discrete and combinatorial mathematics, and usually that's not math I program in an explicit way. I'm really missing some compelling example...

Idiomatic Scala Map manipulation

I'm working with a map in Scala and doing the usual "if there's no value associated with a key, create it, put it in the map and return it": def alphaMemory(key : AlphaMemoryKey) = { var am = map.getOrElse(key, null) if(am == null) { am = new AlphaMemory(key) map.put(key, am) } am } To me, this does not...

What would be a good functional language to pick up?

I come from a background of a large variety of languages but my only experience with functional programming languages was a brief stint with OCaml. I want to dive a lot deeper into one of these languages (Lisp/Scheme, Erlang, Scala, Haskell, etc.) but I want it to hopefully be one that is practical in working environments and also has a ...

Which is the best IDE for Scala development?

I like all three of the popular Java IDE's and all three have plug-ins for Scala. I'll probably try all three eventually, but since I'm totally new to the language I figured I'd ask which is the most full featured Scala IDE? Update: Here is the same question for Scala 2.8 ...

How do I add an edit mode to jEdit?

While looking for a light-weight Scala development environment, I came upon an Scala edit mode for jEdit. I don't know how to put it to use, though. How does one put a new edit mode in jEdit? ...

How do I configure jEdit for Scala projects?

I'd like to be able to use jEdit to write, compile and test projects written in Scala. How can I configure it to do so? ...

How to write eclipse rcp applications with scala?

The Scala Eclipse plugin page says: * Support for Eclipse plugin and OSGi development including hyperlinking to Scala source from plugin.xml and manifest files. How does this support work? There's no wizards for making Scala plugins. I've found no documentation on how to use Scala in a Eclipse plugin/RCP application. Is it even possible...

Unit testing scala actors

Anyone know of a good way to unit test Scala actors? In the general sense I have an actor that receives a message and will send out other messages in response. This is done on multiple threads, and an actor that is not correct may either send the wrong messages or no message at all. I need a simple way of creating a mockup actor that sen...

Scala Programming for Android

I have followed the tutorial at Scala and Android with Scala 2.7.3 final. The resulting Android App works but even the most basic application takes several minutes (!) to compile and needs 900 kb compressed, which is a show stopper for mobile applications. Additionally, the IDE runs out of memory every now and then. I assume dex is not m...

How to write a nice Low-Pass-Filter in Scala

I needed a Low-Pass-Filter in one of my Scala projects and came up with this: def filter(numbers: Seq[Double], filterSize: Int): Seq[Double] = { assert(filterSize > 0) val ringBuffer = new Array[Double](filterSize) var ringBufferIndex = 0 numbers.map(x => { // update ring buffer ringBuffer(ringBufferIndex) = x // i...

scala -> use .net (linq) and java (various frameworks) in the same program?

Hi, Newbie here...can I write one program which incorporates .NET LINQ and also various Java frameworks in the same scala program? Or when I compile, at that time the decision is made either one or the other, .NET or Java Thanks. ...

How does one write the Pythagoras Theorem in Scala?

The square of the hypotenuse of a right triangle is equal to the sum of the squares on the other two sides. This is Pythagoras's Theorem. A function to calculate the hypotenuse based on the length "a" and "b" of it's sides would return sqrt(a * a + b * b). The question is, how would you define such a function in Scala in such a way...

Is there a way in scala to convert from any Map to java.util.Map ?

I use a lot of scala maps, occasionally I want to pass them in as a map to a legacy java api which wants a java.util.Map (and I don't care if it throws away any changes). ...

Is Scalas/Haskells parser combinators sufficient?

I'm wondering if Scalas/Haskells parser combinators are sufficient for parsing a programming language. More specifically the language MiniJava. I'm currently reading compiller construction and jflex and java cup is quite painful to work with so I'm wondering if I could/should use parser combinators instead. The MiniJava syntax is very sm...

Iterating over Java Collections in Scala

I'm writing some Scala code which uses the Apache POI API. I would like to Iterate over the Rows contained in the java.util.Iterator that I get from the Sheet class. I would like to use the Iterator in a for each style loop, so I have been trying to convert it to a native Scala collection but will no luck. I have looked at the Scala Wra...