Hi all!
I am having problems using the update method of scala.collection.immutable.HashMap.I don't see the reason it returns a Map instead of a HashMap. How do I get a new HashMap with a new key-value pair added?
...
What is wrong is the following method?
def someMethod(funcs: => Option[String]*) = {
...
}
...
I have a problem using a parameterized class as the key-type of a Map. First create the parameterized class:
scala> sealed abstract class Foo[T]{ def t: T }
defined class Foo
Now create some imaginary collection of these across unknown parameters:
scala> var l: List[Foo[_]] = Nil
l: List[Foo[_]] = List()
Now create a Map to store ...
Hi All;
Due to Apple's recent T+C hijinks, I've become interested in developing for Android.
Anyways, I'm trying to get a mixed-language Android 2.1 project going in Netbeans 6.8 (with the NBAndroid 0.10 plugin). The two languages being Java and Scala(2.8 head build). To give you a basic idea of what the app does right now, it's just a...
Hi all,
is there a way in Scala to sort an array of tuples using and arbitrary comparison function? In particular I need to sort and array of tuples by their second element, but I wanted to know a general technique to sort arrays of tuples.
Thanks!
...
I'm new to Scala and Lift, coming from a slightly odd background in PLT Scheme. I've done a quick search on this topic and found lots of questions but no answers. I'm probably looking in the wrong place.
I've been working my way through tutorials on using Mapper to create database-backed objects, and I've hit a stumbling block: what typ...
I am not a Groovy expert, but I did read the book "Groovy in Action". In Groovy, each closure comes with a "context", where the items inside the closure can get access to pseudo-variables like "this", "owner", and "delegate", that let the items know who called the closure. This allows one to write DSLs like this (from Groovy in Action):
...
Having trouble coming up with the right name for this class. Basically its a wrapper around a redis data store where writes are "fired off" asynchronously and performed on another thread (to keep the main processing behavior as fast as possible). There are only occasional Get operations and before we can run those we need to make sure th...
I'm new to Scala... Here's the code:
def ack2(m: BigInt, n: BigInt): BigInt = {
val z = BigInt(0)
(m,n) match {
case (z,_) => n+1
case (_,z) => ack2(m-1,1) // Compiler says unreachable code on the paren of ack2(
case _ => ack2(m-1, ack2(m, n-1)) // Compiler says unreachable code on the paren o...
I'm trying to get started with Scala and cannot get out of the starting gate.
A file consisting of the line
package x
gives me
error: illegal start of definition
Regardless of what x is and regardless of where I put the file (I had a theory that I had to place the file in a directory hierarchy to match the package definition, b...
I am new to scala and I am finding the need to convert a boolean value to an integer. I know i can use something like if (x) 1 else 0 but I would like to know if there is a preferred method, or something built into the framework (ie toInt())
...
I'm trying to lex (then parse) a C like language. In C there are preprocessor directives where line breaks are significant, then the actual code where they are just whitespace.
One way of doing this would be do a two pass process like early C compilers - have a separate preprocessor for the # directives, then lex the output of that.
Ho...
Is there a good "scala-esque" (I guess I mean functional) way of recursively listing files in a directory? What about matching a particular pattern?
For example recursively all files matching "a*.foo" in c:\temp.
...
This is the code I used from a book...
import scala.actors.Actor._
val countActor = actor {
loop {
react {
case "how many?" => {
println("I've got " + mailboxSize.toString + " messages in my mailbox.")
}
}
}
}
countActor ! 1
countActor ! 2
countActor ! 3
countActor ! "how many?"
countActor ! "how many?"...
(note, lvalue is actually a term from the C grammar, I don't know what it's called in Scala!)
Trying to learn Scala... this evening I'm working on an internal DSL for a dynamically scoped language that might resemble PHP syntax.
My REPL is: Welcome to Scala version 2.7.6.final (Java HotSpot(TM) Client VM, Java 1.6.0).
I have some made...
I try building the following simple Generator using the Scala 2.8 Continuations-PlugIn.
Where does the following error come from?
None/None/Some((Unit,Unit))
GenTest.scala:8: error: found cps expression in non-cps position
yieldValue(1)
None/None/Some((Unit,Unit))
GenTest.scala:9: error: found cps expression in non-cps position...
Hello,
coming from my other question is there a way to get by-name-parameters for constructors working? I need a way to provide a code-block which is executed on-demand/lazy/by-name inside an object and this code-block must be able to access the class-methods as if the code-block were part of the class.
Following Testcase fails:
pack...
I know that Scala's Lists have a map implementation with signature (f: (A) => B):List[B] and a foreach implementation with signature (f: (A) => Unit):Unit but I'm looking for something that accepts multiple iterables the same way that the Python map accepts multiple iterables.
I'm looking for something with a signature of (f: (A,B) => C...
Given a family of objects that implement parser combinators, how do I combine the parsers? Since Parsers.Parser is an inner class, and in Scala inner classes are bound to the outer object, the story becomes slightly complicated.
Here's an example that attempts to combine two parsers from different objects.
import scala.util.parsing.com...
When trying to import scala.Option in a javafx script, I get the following javafxc error:
bad class file: scala/Option$$anonfun$orNull$1.class(scala:Option$$anonfun$orNull$1.class)
undeclared type variable: A1
Please remove or make sure it appears in the correct subdirectory of the classpath.
import scala.Option;
^
I am u...