scala-2.8

What are the good Scala IDEs at the start of 2010?

元气小坏坏 提交于 2019-12-18 14:23:42
问题 I know this is an exact duplicate, but a year has gone by and Scala seems to be a fast moving thing, so I figure it might be acceptable to ask again: What is the best IDE for Scala development right now? 回答1: I know the Eclipse plugin is a work in progress and undergoing a complete re-write for Scala 2.8 but I saw a colleague use a nightly-build recently and it was extremely poor. I use IntelliJ IDEA (the Community Edition 9 is free) and the scala plugin for it is really good. Excellent

Expand a Set[Set[String]] into Cartesian Product in Scala

纵然是瞬间 提交于 2019-12-18 04:06:38
问题 I have the following set of sets. I don't know ahead of time how long it will be. val sets = Set(Set("a","b","c"), Set("1","2"), Set("S","T")) I would like to expand it into a cartesian product: Set("a&1&S", "a&1&T", "a&2&S", ..., "c&2&T") How would you do that? 回答1: I think I figured out how to do that. def combine(acc:Set[String], set:Set[String]) = for (a <- acc; s <- set) yield { a + "&" + s } val expanded = sets.reduceLeft(combine) expanded: scala.collection.immutable.Set[java.lang

Is the PartialFunction design inefficient?

柔情痞子 提交于 2019-12-18 02:41:25
问题 This is something I've wondered about for a while. I see this pattern a lot: if (pf.isDefinedAt(in)) pf(in) By breaking this up into two separate calls, all of the patterns that were evaluated in #isDefinedAt are then also evaluated in #apply. For example: object Ex1 { def unapply(in: Int) : Option[String] = { println("Ex1") if (in == 1) Some("1") else None } } object Ex2 { def unapply(in: Int) : Option[String] = { println("Ex2") if (in == 2) Some("2") else None } } val pf : PartialFunction

Transforming Scala varargs into Java Object… varargs

主宰稳场 提交于 2019-12-17 18:38:09
问题 I have a Java class that logs stuff which has a method like this: void info(Object message, Object... params); In Scala, I've created a wrapper around such call that looks like this: def info(msg: => String, params: Any*) { log.info(msg, params); } When I call: val host = "127.0.0.1" val port = "1234" info("Start on {0}:{1}", host, port) I get: "Started on WrappedArray(127.0.0.1, 1234):{1}" Now, does anyone now how to convert params into an Object[] that can be consumed properly? I tried to

How do I find out Apache Buildr/Maven 2 repo names

左心房为你撑大大i 提交于 2019-12-17 15:35:19
问题 I'm just starting to use Apache Buildr and I'm constantly running into the problem of not knowing what repo urls and versions are available for me to use. For example I want to use Scala 2.8 in a build file, the id i previously used was: 2.8.0-SNAPSHOT But now this is not found. I also want to use the latest version of Apache POI. If I look on the maven2 repo: http://mirrors.ibiblio.org/maven2/ I can see that it only has up to version 3.2. Is there any standard way of finding repos and

Package objects

筅森魡賤 提交于 2019-12-17 10:14:55
问题 What are package objects, not so much the concept but their usage? I've tried to get an example working and the only form I got to work was as follows: package object investigations { val PackageObjectVal = "A package object val" } package investigations { object PackageObjectTest { def main(args: Array[String]) { println("Referencing a package object val: " + PackageObjectVal) } } } Observations I've made so far are: package object _root_ { ... } is disallowed (which is reasonable), package

Scala Map implementation keeping entries in insertion order?

◇◆丶佛笑我妖孽 提交于 2019-12-17 06:14:32
问题 In Java, I use LinkedHashMap for this purpose. The documentation of Java's LinkedHashMap is very clear that it has "predictable iteration order" and I need the same in Scala. Scala has ListMap and LinkedHashMap , but the documentation on what they do exactly is poor. Question: Is Scala's LinkedHashMap or ListMap the implementation to use for this purpose? If not, what other options are available besides using the Java's LinkedHashMap directly? 回答1: From the LinkedHashMap Scaladoc page: "This

Is the Scala 2.8 collections library a case of “the longest suicide note in history”? [closed]

徘徊边缘 提交于 2019-12-16 22:19:31
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I have just started to look at the Scala collections library re-implementation which is coming in the imminent 2.8 release. Those

scala way to define functions accepting a List of different numeric types

倖福魔咒の 提交于 2019-12-14 00:23:27
问题 I have the following problem: I have a function which takes a List[Double] as parameter, performs some arithmetic operations on the elements of the list and than return the result. I would like the function also to accept List[Int]. Here is an example: def f(l: List[Double]) = { var s = 0.0 for (i <- l) s += i s } val l1 = List(1.0, 2.0, 3.0) val l2 = List(1, 2, 3) println(f(l1)) println(f(l2)) Of course the second println fails since f requires List[Double] and not List[Int]. Also note the

Scala, check if Actor has exited

寵の児 提交于 2019-12-13 13:14:22
问题 in Scala 2.8 when I start actors, I can communicate via message passing. This in turn means that I can send the ultimate Exit() message or whatever I decide fits my protocol. But how will I check if an actor has exited? I can easily imagine myself having a task where a master actor starts some worker actors and then simply waits for the answers, each time checking if this was the final answer (i.e. are any Actors still working or did they all exit?). Of course I can let them all send back an