Is it possible to use Java to create apps that look native on Windows? I don't care if the solution is portable or not, because I only plan to target windows users. I am using Scala if that matters.
Sorry for the lack of details, but I have never used Java before so I'm not even sure if this is possible.
...
In java, common IO operations involving streams, files and the like can be somewhat annoying. Thus I (and many others) tend to reach for things like commons-io to ease the pain.
In scala - are there some better idioms/classes/libraries to use (I know of scala.io.Source etc for reading in text files - but what about streams etc). Is it ...
I have written a simple depth-first search in Scala with a recursive function like that:
search(labyrinth, path, goal)
where labyrinth is a specification of the problem (as graph or whatever), path is a list that holds the path taken so far and goal is a specification of the goal state. The function returns a path to the goal as a Lis...
Can you always structure a recursive function for tail-call elimination? If not, what are other strategies to limit the stack size?
For example:
(inspired by http://stackoverflow.com/questions/1595427/break-or-shortcircuit-a-fold-in-scala)
// Depth-first search of labyrinth, with large depth > stacklimit
def search ( labyrinth: Search...
I have an existing java/scala application using a global thread pool. I would like to start using actors in the project but would like everything in the app using the same pool.
I know I can set the maximum number of threads that actors use but would prefer sharing the thread pool. Is this necessary/reasonable, and is it possible to de...
compiling this code in scala 2.7.6:
def flatten1(l: List[Any]): List[Any] = l.flatten
i get the error:
no implicit argument matching parameter type (Any) = > Iterable[Any] was found
why?
...
this works:
scala> class foo[T] {
| var t: T = _
| }
defined class foo
but this doesn't:
scala> def foo[T] = {
| var t: T = _
| }
<console>:5: error: local variables must be initialized
var t: T = _
why?
(one can use:
var t: T = null.asInstanceOf[T]
)
...
Are there any tools for performing static analysis of Scala code, similar to FindBugs and PMD for Java or Splint for C/C++? I know that FindBugs works on the bytecode produced by compiling Java, so I'm curious as to how it would work on Scala.
Google searches (as of 27 October 2009) reveal very little.
Google searches (as of 01 Februar...
I want to be able to do this:
val myXml = <myTag { someAttributes }> </myTag>
(because I don't know what the attribute details are at compile time)
and this:
val myXml = <{someTag}></{someTag}>
This isn't valid Scala syntax. The closest I can come is using the Elem object to construct elements, but it's being a little troublesome ...
In Scala REPL:
val input = <outerTag xmlns="http://xyz"> <innerTag> </innerTag> </outerTag>
input\\@"innerTag"
=>
<innerTag xmlns="http://xyz"> </innerTag>
How do I stop Scala do this? Why can't it just give me <innerTag> </innerTag>? How can I stop this happening (or remove the xmlns attributes simply)?
Thanks!
Joe
Clari...
I've tried a number of techniques, but I keep bumping into
(fragment of wtf.scala):3: error: overloaded method value + with alternatives
(Int)Int <and> (Char)Int <and> (Short)Int <and> (Byte)Int cannot be applied to (Long)
in one way or another. As an example, here are two functions to reproduce the problem. sumInt works fine... but ...
I would like to achieve something similar to how scala defines Map as both a predefined type and object. In Predef:
type Map[A, +B] = collection.immutable.Map[A, B]
val Map = collection.immutable.Map //object Map
However, I'd like to do this using Java enums (from a shared library). So for example, I'd have some global alias:
type Co...
@lucastex posted about the Java Elvis operator, and I tried something in Scala to get the same effect.
I've just converted everything to a new Structural Type with the ?: operator taking an object of the same type as argument. So Say:
implicit def toRockStar[B](v : B) = new {
def ?:(opt: => B) = if (v == n...
Simple question. Can I do this:
object Xyz extends Actor { ... }
or do Actors have to be classes with instances?
...
I'm learning Scala and I'm trying to store a function in a var to evaluate it later:
var action:() => Any = () => {}
def setAction(act: => Any) {
action = act
}
but that doesn't compile:
error: type mismatch;
found: Any
required: () => Any
action = act
So it seems to me that in action = act instead of assigning the fu...
Okay, this question seems to be really stupid one, but my point is that if you take a look on Scala 2.7.6 API, they had made mappingToString method deprecated. Therefore, there should be more elegant alternative for printing custom-formatted Map. Since for nearly any purpose, having equivalence method of mkString in Map is really handy.
...
I often find myself with an Option[T] for some type T and wish to test the value of the option against some value. For example:
val opt = Some("oxbow")
if (opt.isDefined && opt.get == "lakes")
//do something
The following code is equivalent and removes the requirement to test the existence of the value of the option
if (opt.map(_...
In the Scala actor examples I have seen where a parameterless message is sent to an actor (such as this), case classes (or case objects) have been created and then used as messages. Symbols work just as well and look a bit neater and, after reading a book on Erlang, seem more natural. I assume that symbol equality would work for remote a...
I seem to be missing libraries but I am not certain.
In this file:
object Test {
def main(args: Array[String]) {
for (arg <- args)
println(arg)
}
}
I am not certain what leads to these errors:
Description Resource Path Location Type
Syntax error on token "object", interface expected TestSrc.scala /ScalaDataMining...
I can see that scala can solve the Producer-Consumer problem using actors. There is a couple of examples on the web but what is worrying me is the unlimited growth of an actor's mailbox.
Suppose the producer produces on a much faster rate than the consumer can consume. Using the traditional synchronized threads approach, I can set up a ...