Changing Scala version in existing SBT project.
How can I change Scala version in existing Simple Build Tool project? I would like SBT to check whether the system's Scala version is correct and if it is not the case then download it. ...
How can I change Scala version in existing Simple Build Tool project? I would like SBT to check whether the system's Scala version is correct and if it is not the case then download it. ...
Let me explain this question with an example. If I have a JSON like the following: {"person1":{"name": "Name One", "address": {"street": "Some Street","city": "Some City"}}, "person2":{"name": "Name Two", "address": {"street": "Some Other Street","city": "Some Other City"}}} [There is no restriction on the number of perso...
I had a problem with: <iframe id="iframe1" src='http://stockcharts.com/h-sc/ui?s=MT&p=D&yr=2&mn=0&dy=0&id=p43321191731' width="300px" height="300px"></iframe> in Lift web framework (Scala) version. I get: Message: java.util.NoSuchElementException scala.RandomAccessSeq$$anon$13.next(RandomAccessSeq.scala:165) sca...
I have a number of classes that look like this: class Foo(val:BasicData) extends Bar(val) { val helper = new Helper(val) val derived1 = helper.getDerived1Value() val derived2 = helper.getDerived2Value() } ...except that I don't want to hold onto an instance of "helper" beyond the end of the constructor. In Java, I'd do so...
Given a String list val www = List("http://bloomberg.com", "http://marketwatch.com"); I want to dynamically generate <span id="span1">http://bloomberg.com</span> <span id="span2">http://marketwatch.com</span> def genSpan(web: String) = <span id="span1"> + web + </span>; www.map(genSpan); // How can I pass the loop ind...
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? ...
I'm trying to get this to work: def emptyCond: Parser[Cond] = ("if" ~ "(") ~> regularStr <~ ")" ^^ { case s => Cond("",Nil,Nil) } where regularStr is defined to accept a number of things, including ")". Of course, I want this to be an acceptable input: if(foo()). But for any if(x) it is taking the ")" as part of the regularStr and so ...
Is there a good tutorial showing how to use scala.swing._ ? ...
What are the key differences between ADTs in F# and Scala? Is there anything that F#'s ADTs can do but Scala's ADTs cannot (and vice versa)? ...
I'm a Scala newbie I'm afraid: I'm trying to convert a Map to a new Map based on some simple logic: val postVals = Map("test" -> "testing1", "test2" -> "testing2", "test3" -> "testing3") I want to test for value "testing1" and change the value (while creating a new Map) def modMap(postVals: Map[String, String]): Map[String, String] =...
I'm trying to make a binary tree in scala and need to make a method for it so I'm trying to make functions inside the class that deals with children and parent. I want to make the parent a Tree so that I can recursively call it in another function called getPath but I can't create a Tree inside the Tree class. this is the code: case cl...
Using Scala 2.7.7: If I have a list of Options, I can flatten them using a for-comprehension: val listOfOptions = List(None, Some("hi"), None) listOfOptions: List[Option[java.lang.String]] = List(None, Some(hi), None) scala> for (opt <- listOfOptions; string <- opt) yield string res0: List[java.lang.String] = List(hi) I don't like t...
Why does the following module not compile on Scala 2.8.RC[1,2]? object Test { import util.matching.Regex._ val pVoid = """\s*void\s*""".r val pVoidPtr = """\s*(const\s+)?void\s*\*\s*""".r val pCharPtr = """\s*(const\s+)GLchar\s*\*\s*""".r val pIntPtr = """\s*(const\s+)?GLint\s*\*\s*""".r val pUintPtr = """\s*(const\s+)?GLuint\s*\*\s*"...
for instance in Clojure: user=> (map #(* % 2) (concat [1.1 3] [5 7])) (2.2 6 10 14) but in Scala: scala> List(1.1,3) ::: List(5, 7) map (_ * 2) <console>:6: error: value * is not a member of AnyVal List(1.1,3) ::: List(5, 7) map (_ * 2) ^ Here ::: obtain a list of type List,oops then ...
I wonder if there is a good reason for this optical mismatch between e. g. pattern matching, which uses a simple case foo => to denote that no action should be taken. Wouldn't it be reasonable to have something like import foo.bar.{Baz => } instead of import foo.bar.{Baz => _} considering that _ is used as an "import everythin...
As far as I understand it, there is no way in Scala to have multiple return points in an anonymous function, i.e. someList.map((i) => { if (i%2 == 0) return i // the early return allows me to avoid the else clause doMoreStuffAndReturnSomething(i) // thing of this being a few more ifs and returns }) raises an error: return outs...
For example, val list = List(1,2,3) list match { case a :: b => case _ => } you can match head and tail of a List using :: or tokens of ParseResult using ~. What should I do to create class that can be matched like preceding classes? UPD: And have possibility to write: case class @ ... List(1,2,3,4) match { case 1 @ 2...
Hello! Is there a source, which I could use to learn some of the most used and popular practices regarding Actor-/Agent-oriented programming? My primary concern is about parallelism and distribution limited to the mentioned scheme - Actors, message passing. Should I begin with Erlang documentation or maybe there is any kind of book t...
I was just pottering about with Tony Morris' excellent exercise on catamorphisms, when I was pondering what was happening in the following situation... def cata[X](some: A => X, none: => X): X Let me now call this method as follows: def isDefined: Boolean = cata( _ => true, false) I was wondering whether the type inferencer determi...
Does anybody have good examples of using scala.util.control.Exception? I am struggling to figure it out from the types. ...