Is there an OAuth wrapper library for Scala?
I am looking forward to work with my del.icio.us (authenticated via Yahoo account, so I am going to need OAuth) bookmarks base from a Scala code. Is there a wrapper library out there?
...
I am trying to use a divide-and-conquer (aka fork/join) approach for a number crunching problem. Here is the code:
import scala.actors.Futures.future
private def compute( input: Input ):Result = {
if( pairs.size < SIZE_LIMIT ) {
computeSequential()
} else {
val (input1,input2) = input.split
val f1 = future( compute(inpu...
Hi all,
Pardon my excruciatingly simple question, but I'm quite new to the world of Lift (and Scala, for that matter).
I'm following the "Getting Started" tutorial on the Lift website: http://liftweb.net/getting_started
I've got it up and running but I'd like to make a quick modification to the app so that every time I press enter in...
Hi,
I have this code:
val arr: Array[Int] = ...
val largestIndex = {
var i = arr.length-2
while (arr(i) > arr(i+1)) i -= 1
i
}
val smallestIndex = {
var k = arr.length-1
while (arr(largestIndex) > arr(k)) k -= 1
k
}
But there is to much code duplication. I tried to rewrite this with closures but I failed. I tried somethi...
I have seen a function named implicitly used in Scala 2.8 examples, what is it and how is it used?
Example here:
scala> sealed trait Foo[T] { def apply(list : List[T]) : Unit }; object Foo {
| implicit def stringImpl = new Foo[String] {
| def apply(list : List[String]) = println("String")
| }...
I would like to call the following java method from scala:
protected final FilterKeyBindingBuilder filter(String urlPattern, String... morePatterns) {
return filtersModuleBuilder.filter(Lists.newArrayList(urlPattern, morePatterns));
}
my scala caller looks like this
def test(url: String, urls: String*) {
filter(url, urls: _*).t...
We have a number of Scala classes returning Map[String,String] (key,value) results for storage in a NoSQL database. Some of the results are actually Map[String, List] or Map[String, ArrayBuffer], so we are using .toString on those objects to convert. This gives us output that looks like:
"ArrayBuffer(1,2,3,4)"
or
"List(1,2,4)"
Rath...
For simplicity, imagine that I have a list of lists. I want to display a html table where there is a row for each element of the top-level list and each column in the row is an element of the child list.
So
List(List(1,2,3), List(4,5,6), List(7,8,9))
would result in an html table that is displayed like this:
1 2 3
4 5 ...
If I create an SBT project, even a simple "hello world", compile (successfully) and then exec, the folowing error is thrown. WHat may the reason be and how to fix this?
java.lang.ArrayIndexOutOfBoundsException: 0
at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
at sbt.SimpleProcessBuilder.run(ProcessImpl.scala:381)
...
I have been looking at a couple of books and resources on domain specific languages.
I think I want to build an internal DSL in Scala.
def instrument = new FXInstrument {
provider = "EuroBase"
instrumentOrders = List(
new FXOrder {
baseCcy = "GBP"
termCcy = "EUR"
legs = List(
...
I am currently evaluating Scala for future projects and came across something strange. I created the following constant for us in a JSP:
val FORMATED_TIME = "formatedTime";
And it did not work. After some experimenting I decided to decompile to get to the bottom of it:
private final java.lang.String FORMATED_TIME;
public java.lang.S...
I have the following Scala class:
class Person(var name : String, var age : Int, var email : String)
I would like to use the Person constructor as a curried function:
def mkPerson = (n : String) => (a : Int) => (e : String) => new Person(n,a,e)
This works, but is there another way to accomplish this? This approach seems a bit tedio...
In C++. I can declare most things as const, for example:
Variables: const int i=5;
Scala has val i=5, however this will only prevent reassigning, not changing the object as the following exampe shows:
C++: const int i[]={1,2,3,4};
i[2]=5; //error
Scala: val a=Array(1,2,3,4)
a(2)=5 //a is now Array(1, 2, 5, 4)
It gets even worse with mem...
Hello,
I'm would like to know how could I inherent static field from Java class in Scala.
Here is a Java example, if I a class named ClassFromJava, I could extend it, add some static field, and use the subclass to access the VERSION field.
public class ClassFromJava {
public static int VERSION = 1;
}
public class ClassFromJavaSub...
I am creating a list holding Comparable objects and wish to create one object that serves as the minimum of the list, such that it always returns -1 for its compareTo method. Other methods in the list, like print here requires an input of type A. If I compile the code I get the following error:
error: type mismatch;
found : java.lan...
Hello,
I'm trying to make a compiler plugin available publicly using sbaz.
I followed this tutorial : I packaged my JAR, uploaded it to some public location and ran :
sbaz share scalacl-compiler-plugin-1.0-20101005.advert
sbaz then told me my package was shared, which I seemed to confirm by running sbaz available locally and even sb...
I have a Java method that accepts a Long value:
(in Java)
public void setValue(Long value);
I understand that the Scala null does not extend any of the value types, including Long. Therefore, when I try to pass null to it, I get a compilation error:
(in Scala)
javaThing.setValue(null)
==> type mismatch; found : Any required: java.l...
In SBT project folders hierarchy I am to put my Scala sources in src/main/scala and tests in src/tests/scala. What am I meant to put into src/main/resources and src/tests/resources?
...
My application does large data arrays processing and needs more memory than JVM gives by default. I know in Java it's specified by "-Xmx" option. How do I set SBT up to use particular "-Xmx" value to run an application with "run" action?
...
Why cannot Scala optimize the following:
a.
implicit def whatever[A](a: A) = new { ... }
to:
b.
class some$generated$name(a: A) {
...
}
implicit def whatever[A](a: A) = new some$generated$name(a)
?
Why does it have to use structural typing in this case? I would like Scala compiler to perform this optimization as writing in sty...