Top.Mail.Ru
? ?
Image Scala Developers Forum's Journal
 
[Most Recent Entries] [Calendar View] [Friends]

Below are the 12 most recent journal entries recorded in Scala Developers Forum's LiveJournal:

Thursday, June 19th, 2014
10:21 pm
[ex_juan_gan]
Image
which version?
Guys, which scala version are you currently using? 2.10.3? 2.11?
Friday, August 27th, 2010
6:08 pm
[just_developer]
Image
Newbie question...
How to check that value is tuple of arbitrary length?
Wednesday, June 30th, 2010
1:44 pm
[ex_juan_gan]
Image
Scala Training in SF
Bill Venners and Dick Wall are teaming up to offer a 3 day Scala training
course in San Francisco from August 16th to 18th (details at
http://www.artima.com/seminars/ ).
Friday, July 10th, 2009
6:12 pm
[ex_juan_gan]
Image
scala position, wow!
Sony Pictures Imageworks is seeking a strong programmer to join the middle-tier team. All new large-scale applications are being written in Scala with a large dose of Python client-side scripting.
Read more...Collapse )
Saturday, February 21st, 2009
5:37 pm
[ex_juan_gan]
Image
is it the right way to implement set union?
  def union[X](set1: Set[X], set2: Set[X]): Set[X] = {
    new Set[X] {
      override def contains(x: X) = set1(x) || set2(x)
      override def size = set1.size + set2.size
      override def -(x: X): Set[X] = throw new UnsupportedOperationException
      override def +(x: X): Set[X] = throw new UnsupportedOperationException
      override def empty[Y]: Set[Y] = throw new UnsupportedOperationException
      override def elements = set1.elements ++ set2.elements
    }
  }


Looks like too much overriding, but I could not find a better way.
Saturday, February 14th, 2009
5:48 pm
[ex_juan_gan]
Image
now I'm having stupid questions...
compare this:
    for (Pair(a, b) <- product(this, other)) {}

and this:
    for ((a, b) <- product(this, other)) {}


At least in eclipse plugin the second one show a warning ("constructor cannot be instantiated to required type")

  def product[X, Y](xs: Iterable[X], ys: Iterable[Y]) = {
    for (x <- xs.elements; y <- ys.elements) yield (x, y);
  }


Now, I wonder, what's wrong with the second form?
Tuesday, July 1st, 2008
3:23 am
[_navi_]
Image
intersperse

Is there a good intersperse function in the libraries somewhere? I haven't found, so I have come up with the following function:

  def intersperse(list: Seq[A], e: A): Seq[A] = {
    def intersperseR(cont: List[A] => List[A], list: Seq[A]): Seq[A] {
      if (list.isEmpty) {
        cont(Nil)
      } else {
        intersperseR((rs: List[A]) => cont(e :: list.first :: rs), list.drop(1))
      }
    }
    if (list.isEmpty) {
      Nil
    } else {
      intersperseR((rs: List[A]) => list.first :: rs, list.drop(1))
    }
  }

I must admit, it is kind of ugly. Is there a way to make it simpler? I decided not to convert the list Seq into a List, because I thought it would be less efficient than iterating recursively through the Seq. However, since Seq.drop is lazy (which means that a wrapper is created), probably that was a faux optimization.

Monday, June 23rd, 2008
6:46 pm
[ex_juan_gan]
Image
is there a .... way to iterate through java.util.Iterable?!
Seems like scala does not have a way to walk through a java iterable; it does not have anything like SortedSet either. Tough luck - but why?!
Sunday, June 22nd, 2008
10:58 pm
[ex_juan_gan]
Image
а что это у нас фильтры не ленивые в скале, а?!
println("so, it is " + List.range(4,100000).filter{x => print("" + x + "%2; ")
x % 2 == 0}.forall(x => { println("" + x + "%4")
x % 4 == 0
}))
Wednesday, June 18th, 2008
10:22 am
[ex_juan_gan]
Image
funny bug
Why does not this code compile?


class X(id0:String) {
  override def toString = "X(\"" + id + "\")"
  def id = id0

  override def equals(other : Any) = other match {
      case X(otherId) => otherId == id0
      case _    => false
  }
}
var x = X("abc")
var y = X("abc")
println(X("abc"))
println(x == y)
println(x == new X("abc"))



Well... you should add case before class X
Sunday, June 15th, 2008
10:27 pm
[ex_juan_gan]
Image
some bashing
So, I want in my method to check whether two values are identical. What I have to write is something like this:
def identical(x:Any)(y:Any): Boolean =
  y match {
    case yVal : AnyVal => y == x
    case yRef : AnyRef => y eq x
  }


Not that I mind, but I find it somewhat awkward, and, in case scala becomes a language for millions of code monkeys, a source of immense future confusion.
5:45 pm
[ex_juan_gan]
Image
Welcome!
It is amazing that so far there was no dedicated scala community here. Now there is. Go ahead and start talking. Please! :)
About LiveJournal.com
Image