Search Results

Search found 972 results on 39 pages for 'scala'.

Page 21/39 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • Interesting Scala typing solution, doesn't work in 2.7.7?

    - by djc
    I'm trying to build some image algebra code that can work with images (basically a linear pixel buffer + dimensions) that have different types for the pixel. To get this to work, I've defined a parametrized Pixel trait with a few methods that should be able to get used with any Pixel subclass. (For now, I'm only interested in operations that work on the same Pixel type.) Here it is: trait Pixel[T <: Pixel[T]] { def mul(v: Double): T def max(v: T): T def div(v: Double): T def div(v: T): T } Now I define a single Pixel type that has storage based on three doubles (basically RGB 0.0-1.0), I've called it TripleDoublePixel: class TripleDoublePixel(v: Array[Double]) extends Pixel[TripleDoublePixel] { var data: Array[Double] = v def this() = this(Array(0.0, 0.0, 0.0)) def toString(): String = { "(" + data(0) + ", " + data(1) + ", " + data(2) + ")" } def increment(v: TripleDoublePixel) { data(0) += v.data(0) data(1) += v.data(1) data(2) += v.data(2) } def mul(v: Double): TripleDoublePixel = { new TripleDoublePixel(data.map(x => x * v)) } def div(v: Double): TripleDoublePixel = { new TripleDoublePixel(data.map(x => x / v)) } def div(v: TripleDoublePixel): TripleDoublePixel = { var tmp = new Array[Double](3) tmp(0) = data(0) / v.data(0) tmp(1) = data(1) / v.data(1) tmp(2) = data(2) / v.data(2) new TripleDoublePixel(tmp) } def max(v: TripleDoublePixel): TripleDoublePixel = { val lv = data(0) * data(0) + data(1) * data(1) + data(2) * data(2) val vv = v.data(0) * v.data(0) + v.data(1) * v.data(1) + v.data(2) * v.data(2) if (lv > vv) (this) else v } } Now I want to write code to use this, that doesn't have to know what type the pixels are. For example: def idiv[T](a: Image[T], b: Image[T]) { for (i <- 0 until a.data.size) { a.data(i) = a.data(i).div(b.data(i)) } } Unfortunately, this doesn't compile: (fragment of lindet-gen.scala):145: error: value div is not a member of T a.data(i) = a.data(i).div(b.data(i)) I was told in #scala that this worked for someone else, but that was on 2.8. I've tried to get 2.8-rc1 going, but it doesn't compile for me. Is there any way to get this to work in 2.7.7?

    Read the article

  • are scala's mouse events working? how?

    - by coubeatczech
    Hi, I'm trying to create link-like label in scala. But no mouse events works for me. How are they supposed to work? class Hyperlink extends Label{ text = "hyperlink" reactions += { case MouseClicked(_,_,_,_,_) => println("mouse clicked")}} I put this in some panel and click over the label like a pro minesweeper player... and nothing shows up in console. Why?

    Read the article

  • What are all the instances of syntactic sugar in Scala?

    - by Jackson Davis
    I decided to create this question to have a single source for all things syntactic sugar in Scala. I feel these details are some of the things most frustrating to starting users and are hard to search for since most/all of them are purely symbols and are thus hard to search for without knowing the name of the concept. TODO: implicit conversions _ syntax for anonymous functions Extractors(Unapply/UnapplySeq) Other things I'm forgetting

    Read the article

  • Having a white space issue with scala, I think?

    - by Uruhara747
    I'm trying to write a script to make generating Lift projects quicker but I believe i'm running into a white space issue. val strLiftGen = "mvn archetype:generate -U-DarchetypeGroupId=net.liftweb\ -DarchetypeArtifactId=lift-archetype-blank\ -DarchetypeVersion=1.0\ -DremoteRepositories=http://scala-tools.org/repo-releases-DgroupId=" + args(0)"-DartifactId=" + args(1)"-Dversion=1.0-SNAPSHOT */" Anyone care to hit the newb with the stick of wisdom and tell me a smart way of handling a long string like this?

    Read the article

  • How to sort a list in Scala by two fields?

    - by Twistleton
    how to sort a list in Scala by two fields, in this example I will sort by lastName and firstName? case class Row(var firstName: String, var lastName: String, var city: String) var rows = List(new Row("Oscar", "Wilde", "London"), new Row("Otto", "Swift", "Berlin"), new Row("Carl", "Swift", "Paris"), new Row("Hans", "Swift", "Dublin"), new Row("Hugo", "Swift", "Sligo")) rows.sortBy(_.lastName) I try things like this rows.sortBy(_.lastName + _.firstName) but it doesn't work. So I be curious for a good and easy solution. Thanks in advance! Pongo

    Read the article

  • Getting instance crashes on IntelliJ IDEA with scala plugin.

    - by egervari
    I am building a scala web project using scala test, lift, jpa, hibernate, mercurial plugin, etc. I am getting instant crashes, where the ide just bombs, the window shuts down, and it gives no error messages whatsoever when I am doing any amount of copy/pasting of code. This started happening once my project got to about 100 unit tests. This problem is incredibly annoying, because when the crash happens, 30-60 seconds of activity is not saved. Even IDEA will forget which files were last opened and will forget where the cursor was, which makes it really hard to continue where you left off after the crash. A lot can happen in 60 seconds! Now, I've given up, because it seems like all sorts of things cause the IntelliJ IDEA to crash over and over. For example, if I were to copy and paste this code, to write a similar test for another collection type, it would crash shortly after: it should "cascade save and delete status messages" in { val statusMessage = new StatusMessage("message") var user = userDao.find(1).get user.addToStatusMessages(statusMessage) userDao.save(user) statusMessage.isPersistent should be (true) userDao.delete(user) statusMessageDao.find(statusMessage.id) should equal (None) } There is nothing special about this piece of code. It's code that is working just fine. However, IDEA bombs shortly after I paste something like this. For example, I might change StatusMessage to the new class I want to test cascading on... and then have to import that class into the test... and BOOM... it crashed. On windows 7, the IDEA window literally just minimizes and crashes with no warning. The next time I startup IDEA, it has no memory of what happened. Now, I've had this problem before. I posted it way back on IDEA's YouTrack. I was told to invalidate my caches. That never fixed it then, and it's not fixing it now. Please help. This error is fairly random, but it's happening constantly now. I could program for hours and not see it before... and the fact that my work just gets destroyed and I can't remember what I did during the last minute causes me to swear at my monitor at a db level higher than my stereo can go.

    Read the article

  • Scala - Java = ? (Or Clojure - Java = ?)

    - by Kaveh Shahbazian
    1 - Is it possible for a developer to use Scala without knowing Java? 2 - Is it possible for a developer to use Clojure without knowing Java? Note: For example I am a C# developer and I use .NET without knowing any VB (Of-course WF 4.0 uses VB for statements, so I refuse any projects involving WF 4.0 :) ).

    Read the article

  • What Java/Scala or .NET web frameworks support modify source code and instantly run workflow e.i. wi

    - by Alexey
    As far as I can see the key advantage of dynamic languages like Ruby or Python over Java/Scala/C# etc is "hot" applying of your changes to source code to the running application. What are the frameworks for JVM or .NET that support the same workflow - apply changes to configuration and source code on the fly? Can they also watch changes to custom configurations and notify application? Note: Frameworks for dynamic languages on JVM/.NET like Grails or Compojure are out of scope here.

    Read the article

  • Where can I find documentation for Scala's delayed function calls?

    - by Geo
    I saw a delayed example in David Pollak's "Beginning Scala". I tried to adapt that, by trial and error. Here's what I have: def sayhello() = { println("hello") } def delaying(t: => Unit):Unit = { println("before call") t println("after call") } delaying(sayhello()) How would you delay a function/method that takes parameters? Why can't I use parantheses when I call t? Where can I find more documentation on delaying functions?

    Read the article

  • What could be the Java successor Oracle wants to invest in?

    - by deamon
    I've read that Oracle wants to invest into another language than Java: "On the other hand, Oracle has been particularly supportive of alternative JVM languages. Adam Messinger ( http://www.linkedin.com/in/adammessinger ) was pretty blunt at the JVM Languages Summit this year about Java the language reaching it's logical end and how Oracle is looking for a 'higher level' language to 'put significant investment into.'" But what language could be the one Oracle wants to invest in? Is there another candidate than Scala?

    Read the article

  • Map multiple functions over a single data item

    - by Linus Norton
    I'm in the process of learning Scala and I came across a scenario today where I need to map multiple functions over a single piece of data and wondered if there was a formal name for this. It sort of feels like the inverse of map. I'm not sure this is the correct way of expressing it, but this is what I did: dmap(x: Object, fns: List[Function]) = fns.map(_(x)) Is there a built in way to do something similar? Is there a formal name for this function?

    Read the article

  • Ideas for pet concurrent applications [closed]

    - by DJoyce
    As part of research I am doing into functional concurrent programming, I am looking to develop a prototype business application (or otherwise), that requires and supports parallelism. So I will first develop this application in java 7, followed by scala and then clojure while demonstrating the concurrent support in each language. However, I am a little short on suitable ideas and therefore i'm hoping I can get some good, interesting ideas on this thread. Thanks!

    Read the article

  • Typesafe obtient 14m de $ pour pousser Scala en avant, un financement destiné à accroître la popularité du langage

    Typesafe obtient 14m de $ pour pousser Scala en avant Un financement destiné à accroître sa popularité Avec l'aide de fonds nouvellement obtenus de Shasta Ventures et Juniper Networks, Typesafe va intensifier la promotion du langage de programmation Scala dans le monde de l'entreprise. Selon Mark Brewer, CEO de Typesafe, Scala était surtout utilisé par les grosses applications Web telles que Twitter, LinkedIn ou Foursquare. Mais depuis environ un an, on commence à voir de plus en plus de développeurs préférer Scala à Java pour la création d'applications de gestion traditionnelles. Toujours selon Brewer, beaucoup d'entre eux trouveraient Scala plus léger et plus commode que Java. ...

    Read the article

  • I'm having an issue with a scala script using 2.7.7 - Main$$anon$1$$anonfun$1$$anonfun$apply$2

    - by Uruhara747
    This is the code I used from a book... import scala.actors.Actor._ val countActor = actor{ loop { react{ case "how many?" = { println("I've got " + mailboxSize.toString + " messages in my mailbox.") } } } } countActor ! 1 countActor ! 2 countActor ! 3 countActor ! "how many?" countActor ! "how many?" countActor ! 4 countActor ! "how many?" The error java.lang.NoClassDefFoundError: Main$$anon$1$$anonfun$1$$anonfun$apply$2

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >