scala

scala implicit or explicit conversion from iterator to iterable

Does Scala provide a built-in class, utility, syntax, or other mechanism for converting (by wrapping) an Iterator with an Iterable? For example, I have an Iterator[Foo] and I need an Iterable[Foo], so currently I am: val foo1: Iterator[Foo] = .... val foo2: Iterable[Foo] = new Iterable[Foo] { def elements = foo1 } This seems ug...

is there any scala network library with actor model

hi all i'm now to scala. i need a network library with actor model. or the best choise is java.nio? ...

dynamically create class in scala, should I use interpreter?

Hi, I want to create a class at run-time in Scala. For now, just consider a simple case where I want to make the equivalent of a java bean with some attributes, I only know these attributes at run time. How can I create the scala class? I am willing to create from scala source file if there is a way to compile it and load it at run tim...

Overloading on return type?

scala> val shares = Map("Apple" -> 23, "MicroSoft" -> 50, "IBM" -> 17) shares: scala.collection.immutable.Map[java.lang.String,Int] = Map(Apple -> 23, MicroSoft -> 50, IBM -> 17) scala> val shareholders = shares map {_._1} shareholders: scala.collection.immutable.Iterable[java.lang.String] ...

Interesting Scala typing solution, doesn't work in 2.7.7?

I'm trying to build some image algebra code that can work with images (basically a linear pixel buffer + dimensions) that have different types for the pixel. To get this to work, I've defined a parametrized Pixel trait with a few methods that should be able to get used with any Pixel subclass. (For now, I'm only interested in operations ...

Java or Scala for new greenfield projects ?

Hi, After I read Bloch's discussion http://www.infoq.com/news/2010/04/bloch_java_future I started to think about "Do I have to switch to scala for new web developements" or is java preferred in all cases. What is your opinion ? Thanks, ...

initialise a var in scala

I have a class where I like to initialize my var by reading a configfile, which produces intermediate objects/vals, which I would like to group and hide in a method. Here is the bare minimum of the problem - I call the ctor with a param i, in reality a File to parse, and the init-method generates the String s, in reality more complicate...

Can anyone suggest a Java or Scala DOS/terminal-based UI framework?

I'm looking for some framework to build an interface like Turbo C. ...

What is/are the Scala way(s) to implement this Java "byte[] to Hex" class

I'm specifically interested in Scala (2.8) techniques for building strings with formats as well as interesting ways to make such a capability easily accessible where it's useful (lists of bytes, String, ...?).. public class Hex { public static String valueOf (final byte buf[]) { if (null == buf) { return null; } fina...

a scala remote actor exception

hi all i with a scala code like this for echo service. import scala.actors.Actor import scala.actors.Actor._ import scala.actors.remote.RemoteActor._ class Echo extends Actor { def act() { alive(9010) register('myName, self) loop { react { case msg => println(msg) } } } ...

Targeting Android with Scala 2.8 Trunk builds

The definitive reference for using Scala on android seems to be here: http://www.scala-lang.org/node/160 Unfortunately, all the references on using scala with android are based around Scala 2.7 and refer to a custom build android-library.jar, with a couple of cryptic references suggesting that this custom build isn't needed for later ve...

How would I yield an immutable.Map in Scala?

I have tried this but it does not work: val map:Map[String,String] = for { tuple2 <- someList } yield tuple2._1 -> tuple2._2 How else would I convert a List of Tuple2s into a Map? ...

Enhance Predefined Methods in Scala

Base question: Why can I write in Scala just: println(10) Why don't I need to write: Console println(10) Followup question: How can I introduce a new method "foo" which is everywhere visible and usable like "println"? ...

Scala methods ending in _=

I seem to remember Scala treating methods ending in _= specially, so something like this: object X { var x: Int = 0; def y_=(n : Int) { x = n }} X.y = 1 should call X.y_=(1). However, in 2.8.0 RC1, I get an error message: <console>:6: error: value y is not a member of object X X.y = 1 ^ Interestingly, just trying t...

ensime scala errors (class scala.Array not found, object scala not found)

I've installed ensime according to the README.md file, however, I get errors in the inferior-ensime-server buffer with the following: INFO: Fatal Error: scala.tools.nsc.MissingRequirementError: object scala not found. scala.tools.nsc.MissingRequirementError: object scala not found. at scala.tools.nsc.symtab.Definitions$definitions$...

scala syntax highlighting in bluefish

Scala comes packaged with bluefish syntax config in misc/scala-tool-support/bluefish/ I have attempted to configure this, as per the README, but there is no effect. cp ~/.bluefish/highlighting ~/.bluefish/highlighting_ cat ~/.bluefish/highlighting_ /opt/scala/scala-2.7.7.final/misc/scala-tool-support/bluefish/highlighting > ~/.bluefis...

capture types of varargs parameters

Hi, I'd like to define a method accepting varargs, so that I get the types with which it was called even in the case of nulls. def foo(args: Any*) = .... val s: String = null foo(1, s) // i'd like to be able to tell in foo that args(0) is Int, args(1) is String ...

Composing independent traits

Given two independent traits: trait T1 { def x = 42 } trait T2 { def x = 0 } If I try to define a class mixing in these two traits like: class C extends T1 with T2 I get a compiler error: error: overriding method x in trait T1 of type => Int; method x in trait T2 of type => Int needs `override' modifier class C extends T1...

Does anybody know of a GUI DSL for Scala?

hi all does anybody knows a scala dsl on gui programming. regards. kula ...

Scala match/compare enumerations

I have an enumeration that I want to use in pattern matches in an actor. I'm not getting what i'd expect and, now, I'm suspecting I'm missing something simple. My enumeration, object Ops extends Enumeration { val Create = Value("create") val Delete = Value("delete") } Then, I create an Ops from a String: val op = Ops.valueOf("c...