This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Problem 1 in scala | |
| */ | |
| (for(i <- 1 until 999) yield i).filter(n => (n % 3 == 0 || n % 5 == 0)).sum | |
| /** | |
| * Problem 2 in scala | |
| */ | |
| lazy val fib: Stream[Int] = Stream.cons(0, Stream.cons(1, fib.zip(fib.tail).map(p => p._1 + p._2))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class A | |
| class A2 extends A | |
| class B | |
| trait M[X] | |
| // | |
| // Upper Type Bound | |
| // | |
| def upperTypeBound[AA <: A](x: AA): A = x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import scalaz._ | |
| /** | |
| * playing with some of the ideas from the Haskell fclabels library | |
| * using the new Lens functionality in scalaz | |
| * | |
| * http://hackage.haskell.org/package/fclabels | |
| */ | |
| object LensTest { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package eu.getintheloop.snippet | |
| // Author: Timothy Perrett | |
| // Date: 11th April 2011 | |
| case class Product(name: String, price: Long) | |
| import net.liftweb.util.CssSel | |
| object Bindings { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // See http://lampsvn.epfl.ch/trac/scala/ticket/967. | |
| // | |
| // Gilles' fix causes the definition of Nat to be rejected with the error | |
| // "Parameter type in structural refinement may not refer to a type member | |
| // of that refinement". However we can work around the problem by | |
| // quantifying out the problematic parameter type and reinstating it via | |
| // a generalized type constraint. | |
| type Num = { | |
| type Rep |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| object Bindings { | |
| class Bind[T](what: T){ | |
| def bind[DataBinding[T]] = implicitly(what) | |
| } | |
| type DataBinding[T] = T => CssSel | |
| implicit def asCssSelector[T](in : T): Bind[T] = new Bind[T](in) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| java.lang.AssertionError: assertion failed: adapt akka.dispatch.Future.apply$default$2():()Long to Long | |
| at scala.tools.nsc.transform.Erasure$Eraser.adaptToType(Erasure.scala:533) | |
| at scala.tools.nsc.transform.Erasure$Eraser.adapt(Erasure.scala:658) | |
| at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4208) | |
| at scala.tools.nsc.typechecker.Typers$Typer.typedArg(Typers.scala:2202) | |
| at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$typedArgs$3.apply(Typers.scala:2212) | |
| at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$typedArgs$3.apply(Typers.scala:2211) | |
| at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:206) | |
| at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:206) | |
| at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| case class XSetTrackingParameter(inTicketID: Option[String], | |
| inParam: xmpiewsapi.XParameter) | |
| case class XParameter(m_Name: Option[String], | |
| m_Value: Option[String]) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package sbt { | |
| import org.glassfish.embeddable.{GlassFish, GlassFishRuntime, GlassFishProperties, Deployer} | |
| trait GlassFishPlugin extends BasicWebScalaProject { | |
| def glassFishPort = GlassFishRunner.DefaultPort | |
| private lazy val glassFish = new GlassFishRunner(glassFishPort, temporaryWarPath) | |
| lazy val glassfishRun = glassfishRunAction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Aggregator(recipients: Iterable[ActorRef]) extends Actor{ | |
| def receive = { | |
| case msg @ Message(text) => | |
| println("Started processing message `%s`" format(text)) | |
| val result = Promise[String]() | |
| val promises = List.fill(recipients.size)(Promise[String]()) | |
| recipients.zip(promises).map{case (recipient, promise) => |