When I first started looking at Scala, I liked the look of for-comprehensions. They seemed to be a bit like the foreach loops I was used to from Java 5, but with functional restrictions and a lot of sweet syntactic niceness.
But as I've absorbed the Scala style, I find that every time I could use a for-comprension I'm using map, flatMap...
I'm trying to learn how to use lift. I can create project skeleton by running maven commands (I had zero maven experience before) from Starting with Lift. It successfully downloads needed dependencies and everything works fine, however it does not download sources - I'd like to see how lift works from inside.
Looks like it downloads de...
In Scala I can do this:
trait SomeTrait {
protected def foo: String
}
class Wibble extends SomeTrait {
protected var foo = "Hello"
}
But I cannot do the same thing where I provide a default definition for foo
trait SomeTrait {
protected def foo: String = "World"
}
class Wibble extends SomeTrait {
protected var foo = "Hello"...
Does anyone know how to do this?
...
When writing the following code in scala
var m = Map((0,1) -> "a")
m += ((0,2), "b") // compilation error
I'm getting the error
type mismatch;
found : Int(0)
required: (Int, Int)
However the changing the syntax of the tuple from (X,Y) to (X -> Y) works
var m = Map((0,1) -> 'a)
m += ((0,2) -> 'b) // compiles file
Even though...
What I think would be useful for me (and hopefully for other SO readers and Scala fans) is:
How to painlessly set up lift on linux (ubuntu) (apt-get install lift #does not work)
Is there any free server where I can run lift and Scala?
I have no experience with Java or maven or Eclipse.
(but have some experience with functional progra...
I just start learning Scala and I find it fascinating.
I went through this course and it was nice.
Now I'm looking for some not-too-big exercises. Preferably with neat solutions so when I create my own I can learn :)
...
Is there a succinct example of how to upload an image, resize it, store it in a database and then serve the image up using Lift?
I'm sure I could piece it together from the file upload, Java 2D API, Lift Mapper and Response APIs. But is there any example code I can follow to do it the 'correct' or recommended way?
...
I've been wondering whether transparent implicit conversions are really such a good idea and whether it might actually be better to use implicits more, um, explicitly. For example, suppose I have a method which accepts a Date as a parameter and I have an implicit conversion which turns a String into a Date:
implicit def str2date(s: Stri...
I'm planning to broaden my perspectives in JVM platform, and I've got a dilemma: what should I learn first? Could you please explain, what are the advantages of Groovy, Scala and other languages for JVM? Thanks.
...
I am new to Scala, just started learning, so this is basic beginner question.
I try to implement Sieve of Eratosthenes algorithm. Here is what I got so far:
def sieve_core(cross: Int, lst: Seq[Int]): List[Int] = {
val crossed = lst.filter(_ % cross != 0)
crossed match {
case a :: rest => cross :: sieve_core(a, cros...
I am a Scala newbie, just starting to learn the language.
I solved Problem 8 from Project Euler page.
The code looks like this (I removed all the code to do with reading of an input file):
def max(n1: Int, n2: Int): Int = Math.max(n1, n2)
def max_product(digits: List[Int], num: Int): Int = {
def max_core(lst: List[Int], curr_max...
I'm looking into LINQ and the query language appears (at least on the surface) to be nothing more than an implementation of map and/or list comprehensions as found in Haskell and other FP languages (particularly the generalisation of 'map' and 'for' in Scala). Is this correct? Is there more to the syntax than this? From the breathless to...
I have always liked the auto-compilation feature of jEdit with Scala sources. Now, however, I'm using "mvn scala:cc" and JavaRebel with a Lift project, which provides better compilation than what jEdit does, and I'd like to disable jEdit's auto-compilation.
How do I disable auto-compilation in jEdit, of Scala sources, in particular?
...
What is the (or a) recommended way to implement security for Scala Remote Actors (authentication of remote nodes allowed to speak to this actor, and encryption of the contents of the discussion)? Has anyone done this; how did it work out?
SSL...
some Java library...
some JSR...
custom serialization...
only VPN is going to work on this...
How to render Processing.org images on Java servlet?
My scala code is:
class Image extends PApplet {
override def setup {
size(200,200)
background(0)
}
override def draw {
stroke(255)
line(10,10,50,50)
}
def renderImage = g.getImage
}
class ImageServlet extends HttpServlet {
override def doGet(request: ...
I'm trying to get a better grasp of structural type dispatch. For instance, assume I have an iterable object with a summary method that computes the mean. So o.summary() gives the mean value of the list. I might like to use structural type dispatch to enable summary(o).
Is there a set of best practices regarding o.summary() vs. su...
What's the best way to persist user state with Tomcat/Scala? My first thought is to keep account information on the session at all times and redirect the user to a login page if there's no information on the session for the account. Is this a viable model, or is there a smarter way of persisting user information? I'm trying to replicate ...
Hi,
Java has:
public void someMethod(int ... intArray) { // question: what is the equivalent to "..."
// do something with intArray
}
how can I achieve the same functionality in Scala? That is, passing an undefined number of parameters to a method?
...
Recommendations for languages with native (so no FSM generation tools) support for state machine development and execution and passing of messages/signals. This is for telecoms, e.g implementation of FSMs of this level of complexity.
I have considered Erlang, but would love some feedback, suggestions, pointer to tutorials, alternatives,...