scala-2.8 Questions

4

Solved

Is there a method to do the following without doing both methods: find and map? val l = 0 to 3 l.find(_ * 33 % 2 == 0).map(_ * 33) // returns Some(66)
Beano asked 29/3, 2011 at 21:34

4

Solved

I'm writing a code generator which produces Scala output. I need to emulate a ternary operator in such a way that the tokens leading up to '?' remain intact. e.g. convert the expression c ? p : q...
Grits asked 24/4, 2010 at 19:54

3

Solved

What is the most succinct Scala way to reverse a Map? The Map may contain non-unique values. EDIT: The reversal of Map[A, B] should give Map[B, Set[A]] (or a MultiMap, that would be even better)....
Bituminize asked 9/9, 2010 at 17:25

3

Solved

Environment : Scala 2.10+ IDE : Eclipse Kepler I have a line NAME=bala AGE=23 COUNTRY=Singapore How can I get it as a map Map(NAME -> bala, AGE -> 23, COUNTRY -> Singapore)
Dorsad asked 28/2, 2014 at 8:54

3

Solved

I've wrapped a Message and would like to log which message I've wrapped. val any :Any = msg.wrappedMsg var result :Class[_] = null The only solution I could find is matching everything: result ...
Steradian asked 29/6, 2010 at 10:39

2

Solved

I need to call scala code from java, so I need to tell the compiler that a certain method throws certain exceptions. This is easy to do for one exception, but I'm struggling to declare that a metho...
Spada asked 12/12, 2013 at 13:21

1

Solved

I am looking for an implementation of an immutable priority queue for at least Scala 2.8, but preferably more current. Is there a good implementation somewhere?
Relativistic asked 8/8, 2013 at 13:33

5

I would like to construct my domain model using immutable objects only. But I also want to use traits with val fields and move some functionality to traits. Please look at the following example: t...
Forthright asked 11/8, 2010 at 14:51

2

Solved

When I evaluate a for in Scala, I get an immutable IndexedSeq (a collection with array-like performance characteristics, such as efficient random access): scala> val s = for (i <- 0 to 9) yi...
Inshore asked 1/6, 2010 at 7:18

3

Solved

scala> val m = Map(1 -> 2) m: scala.collection.immutable.Map[Int,Int] = Map(1 -> 2) scala> m.map{case (a, b) => (a+ 1, a+2, a+3)} res42: scala.collection.immutable.Iterable[(Int, In...
Motorboat asked 7/4, 2010 at 11:36

4

Solved

I'm trying to write a trait (in Scala 2.8) that can be mixed in to a case class, allowing its fields to be inspected at runtime, for a particular debugging purpose. I want to get them back in the o...
Ticktock asked 8/2, 2010 at 19:27

5

Solved

As an exercise, I'd like to extend the Scala Array collection to my own OneBasedArray (does what you'd expect, indexing starts from 1). Since this is an immutable collection, I'd like to have it re...
Rumanian asked 7/12, 2010 at 21:52

2

I am currently Play!ing with Play 2.0 (Scala). I must admit that it's a lot of fun. I have a question though related to database operations exceptions. Let's say I have Car as a domain class and t...
Fado asked 16/7, 2012 at 19:56

2

Solved

Following on from another question I asked, Scala 2.8 breakout, I wanted to understand a bit more about the Scala method TraversableLike[A].map whose signature is as follows: def map[B, That](f: A...
Theorist asked 12/11, 2009 at 10:38

4

Solved

I have a two lists, a List[A] and a List[B]. What I want is a Map[A,B] but I want the semantics of zip. So started out like so: var tuplesOfAB = listOfA zip listOfB Now I'm not sure how to const...
Beebe asked 3/2, 2010 at 4:52

2

Solved

I'm probably doing something stupid, but I can't spot it. I've installed Eclipse Helios (Helios because I couldn't get Glassfish support to work correctly using Gallileo) and the nightly build of ...
Glide asked 15/12, 2010 at 11:5

2

Solved

Scala's handling of superclass constructor parameters is confusing me... with this code: class ArrayElement(val contents: Array[String]) { ... } class LineElement(s: String) extends ArrayElemen...
Waterloo asked 27/12, 2011 at 10:51

7

I have recently been looking around to learn a new language during my spare time and Scala seems to be very attractive. I have a few questions regarding it: Will not knowing Java impose a challa...
Content asked 28/2, 2010 at 15:5

2

Solved

Consider the following: scala> val a:java.lang.Boolean = true a: java.lang.Boolean = true scala> val b = true b: Boolean = true scala> a == b res4: Boolean = true scala> b == a <...
Lowermost asked 16/10, 2011 at 9:40

1

Solved

Making a migration from 2.8.1 to 2.9.1 found interesting thing. Tried to write this in console: >>import collection.immutable.Set.Set4 >>new Set4[Int](1,2,3,4) It gives: java.lang.E...
Conscription asked 15/9, 2011 at 13:6

1

Solved

I am working on project implemented in scala 2.8.1, want to migrate to scala 2.9.1 and use akka-actors libraries instead of standard, but didn't find good summary of main changes, here what I found...
Malnutrition asked 15/9, 2011 at 6:21

3

Solved

I have an asynchronous control-flow like the following: ActorA ! DoA(dataA, callback1, callbackOnErrorA) def callback1() = { ... ActorB ! DoB(dataB, callback2, callbackOnErrorB) } def callback...
Tosha asked 15/3, 2010 at 11:41

3

Solved

This works def func(f: => Int) = f This dosn't (inside class for example) type EmptyFunct = => Int or type EmptyFunct = (=> Int) Scala version 2.9 Two questions: Why dosn't syn...
Sorption asked 29/8, 2011 at 10:19

9

Solved

I recently gave up trying to use Scala in Eclipse (basic stuff like completion doesn't work). So now I'm trying IntelliJ. I'm not getting very far. I've been able to edit programs (within syntax h...
Aggregation asked 19/4, 2010 at 14:25

4

Solved

Total newbie question here...Today while trying to calculate sum of a list of integers(actually BitSet), I ran into overflow scenarios and noticed that the return type of(sum/product) is Int. Are t...
Camilacamile asked 26/8, 2011 at 6:17

© 2022 - 2024 — McMap. All rights reserved.