Skip to main content

Posts

Showing posts with the label scala

Finished Exercise #1 for Scala

I've just finished exercise #1 from: knowing.net . Please feel free to critique this code, I am serious about learning Scala and getting introduced to members of the community. Calculator.scala package activeactive class Calculator { def main(args:Array[String]): Double = eval(args.toList) def eval(args:List[String]): Double = args match { case null => throw new IllegalArgumentException( "args cannot be null-valued") case Nil => throw new IllegalArgumentException( "You must provide a function name as the first argument") case "sum" :: rest => sum(convertList(rest)) case "prod" :: rest => product(convertList(rest)) case "mean" :: rest => mean(convertList(rest)) case "sqrt" :: rest => sqrt(convertList(rest)) case _ => throw new IllegalArgumentException( "invalid function name. Use 'sum', 'prod...

HelloWorld in Scala with the Eclipse Plug-in

The Eclipse plug-in for Scala makes you jump through two hoops before letting you run your application from the Run... menu: Your main object must extend Application. Since main is now overridden, you must use the override keyword on the method definition. package activeactive object Main extends Application { override def main(args:Array[String]) { println("Hello World!") } }

Learning Scala

I attended Stuart Halloway's dynamic language shoot-out presentation at NFJS last night. Ruby, Clojure, and Scala are the three languages in which he spent his time. Stuart claimed that each of these languages were made to run on the JVM in order to piggy-back on the penetration of the JVM in the enterprise. The choice of language you make is mostly unimportant, most of these interesting languages on the JVM provide the same general additions to Java running on the JVM. I intend to learn Scala this year. I feel that Ruby has a lot of penetration in the software development field, but that Scala is the up-and-coming language. I believe that the concepts and idioms in the languages are common enough to allow me to easily learn Ruby next year. My plan of attack for learning Scala: Install Eclipse 3.4. Install the Scala plug-in from: http://www.scala-lang.org/tools/eclipse/index.html . Create a working hello world program. Complete the exercises from: http://www.knowing.net/index.ph...