scala

scala 2.8 collections inconsistency?

why the methods transform (in-place mutation version of map) and retain (in-place mutation version of filter) are defined on only mutable.Map but not on mutable.Buffer and mutable.Set? shouldnt all mutable collections support these methods? ...

Introducing scala into existing netbeans java project

Hi, I have an existing java project in Netbeans. I would like to start coding parts of it in Scala. I can add ".scala" files to the project but apparently they aren't compiled. Can I somehow modify the existing Netbeans project settings in order to build java and scala sources together or do I need to create a new project and import th...

[JOGL] Rotating text using Textrenderer

Hey, I'd like to display text in a 2D szenario using JOGL. But I can't figure out, how to rotate text using com.sun.opengl.util.j2d.TextRenderer. It does not have any methods concerning the rotation. So I was expecting the modelview matrix to have an effect on the rotation. val renderer = new TextRenderer(new Font("SansSerif", Font.BOLD...

Is there Scala plugin for Eclipse Helios (3.6)?

I have Eclipse Helios (3.6). I found one Scala plugin on Eclipse marketplace, but there was no "Install" button and description said there is no version of this plugin for Eclipse Helios. Is it possible to develop Scala on Eclipse Helios? How? ...

Changing Scala Swing ComboBox Items

I tried to implement a date selection using three ComboBox as shown below. contents += new Label("Selected Date:") val dayBox = new ComboBox(1 to 31) contents += dayBox val monthBox = new ComboBox(List("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")) contents += monthBox listenTo(monthBox.selection) r...

implicit value not found

class Test { import scala.collection._ class Parent class Child extends Parent implicit val children = mutable.Map[String, Child]() def createEntities[T <: Parent](names: String*) = names.foreach(createEntity[T]) def createEntity[T <: Parent](name: String)(implicit map: mutable.Map[String, T]): Unit = map.get...

Covariant Typeparameter in scala needs to be invariant in java interface

hi there I've got a trait that looks like this (some further information can be found at this related question by myself although I don't think, it's needed for this question) trait Extractor[-A,+B] { def extract(d:A):B //lots of other things } To use this in an existing java framework I would like this Extractor to either have a...

Is Java *really* less complex than Scala?

I frequently hear claims that Scala is much more "complex" than Java. Can anyone therefore provide an example of Java code that can't be improved by writing it in Scala, or Scala code that can be improved by writing it in Java (but not by just rewriting within Scala) By "improve", I mean that the code is better with regards to one (or ...

How do I make a (minimal) runnable jar file from a scala eclipse project

I have made a runnable jar using this process: http://garyboone.com/2009/06/creating-single-file-runnable-jars-in-scala-and-eclipse/?wscr=1366x768 editing the ant build.xml to include scala-library.jar (5.9 MB) Isn't i possible somehow to get eclipse to extract the needed parts of scala-library.jar? So I can get a smaller, less bloated ...

Copy objects in scala but changing "children" for rewriting

In kiama a generic "dup" method is defined which copies Product objects and applies a given function to each of the elements of the Product in order to support rewriting of Terms: /** * General product duplication function. Returns a product that applies * the same constructor as the product t, but with the given children ...

What's the equvalent to .Net ArrayList mutable type in Scala 2.8?

What type in Scala 2.8 can I use to store a list of values? In C# I'd use ArrayList. ...

Scala coding styles and conventions ?

I think Scala goes too far from simplicity, like its syntax. For example Martin Odersky wrote the method in his book : def calculate(s: String): Int = if (cache.contains(s)) cache(s) else { val acc = new ChecksumAccumulator for (c <- s) acc.add(c.toByte) val cs = acc.checksum() cache += (s -> cs) cs }...

Scala $ operator

Has Scala a Haskell-like $ operator? ...

Are there any means in Scala to split a class code into many files?

There are 2 reasons for me to ask: 1. I'd like a better code fragmentation to facilitate version control on per-function level 2. I struggle from some attention deficit disorder and it is hard for me to work with long pieces of code such as big class files To address these problems I used to use include directives in C++ and partial c...

Lift - Page displays as XML in Firefox rather than HTML

I'm trying to get a simple Lift example running and I'm having a strange issue. I am using the Sonatype sample list project here. I modified the HTML slightly, but it wasn't working originally either. The issue I'm having is that when I run the local jetty server and try to access http://localhost:8080 it displays as XML in Firefox 3.6.1...

Scala Swing Wait

//Main.scala /* imports */ object Main extends SimpleSwingApplication { lazy val ui = new TabbedPane { /* contents */ } def top = new MainFrame { /* contents */ } override def startup(args: Array[String]) { val t = top val loginStatus = new Login(t).status if (loginStatus == true) { if (t.size == ...

How to build/test Scala without IDE dependence?

I'm well into learning Scala now and enjoying it very much; I hope to start future projects in it, rather than Java. What I'm enjoying less is the (relatively) poor IDE support. I've found both IDEA and Eclipse with the Scala Plugin (including nightly builds) to be a bit unreliable or difficult to use - I want something I can always de...

Modifying multiple Lists inside a function and returning it in Scala

I have a List of type [T] and [B] in scala, with an object e of type E. I want to make a function that accepts those three parameters: def doSomething(t : List[T], b List[B], e : E) { ... } However I realise that List is immutable, and anything passed to a function is considered as val (not var). But I need to modify t and b and ret...

Bidirectional reference with case classes

Is it possible to implement a bi-directional tree in a case class. This seems like it should be easy, but I'm getting stumped case class Node(name:String, parent:Option[Node], children:List[Node]) I want to add a child (and get a new root) -- something like def addChild(n:String):Node = { Node(name, parent, Node(n, Some(this), Nil...

Unexpected Scala pattern matching syntax

I had a List of Scala tuples like the following: val l = List((1,2),(2,3),(3,4)) and I wanted to map it in a list of Int where each item is the sum of the Ints in a the corresponding tuple. I also didn't want to use to use the x._1 notation so I solved the problem with a pattern matching like this def addTuple(t: (Int, Int)) : Int = ...