This file contains 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 com.felstar.playpen.scalaxb | |
import java.io.File | |
object PostProcessScalaxb { | |
def allFiles(path:File):List[File]= { | |
val (dirs,files)=path.listFiles.toList.partition(_.isDirectory) | |
files ::: dirs.flatMap(allFiles) | |
} |
This file contains 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 com.barclays.buyit.mgs | |
import java.util.Date | |
import com.espertech.esper.client._ | |
import scala.beans.BeanProperty | |
object EsperTest extends App { | |
case class Tick(@BeanProperty symbol:String,@BeanProperty price:Double,@BeanProperty timestamp:Long=System.currentTimeMillis) |
This file contains 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 com.felstar.xqs.example | |
import com.felstar.xqs.XQS._ | |
import com.felstar.xqs.XQS.AllImplicits._ | |
import xml.PrettyPrinter | |
import com.xqj2.XQConnection2 | |
object BaseXEmbeddedXQS extends App { |
This file contains 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 SunSpot { | |
def main(args: Array[String]): Unit = { | |
type Cube = Array[Array[Int]] | |
def sumCube(arr: Cube):Int = arr map (_.sum) sum | |
def getSampleCube(cube: Cube, y: Int, x: Int): Cube = cube.slice(y - 1, y + 2) map (_.slice(x - 1, x + 2)) | |
def toCube(st: String, size: Int): Cube = st.split(" ").map(_.toInt).grouped(size).toArray |
This file contains 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
Exercise | |
Implement a console-based social networking application (similar to Twitter) satisfying the scenarios below. | |
Scenarios | |
Posting: Alice can publish messages to a personal timeline | |
> Alice -> I love the weather today | |
> Bob -> Oh, we lost! | |
> Bob -> at least it's sunny |
This file contains 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 org.scalajs.dom | |
// Paste here http://www.scala-js-fiddle.com/ | |
// Ctrl-enter to recompile | |
@JSExport | |
object ScalaJSExample{ | |
type Coord = Pair[Int, Int] | |
type CoordSet = Set[Coord] |
This file contains 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
val that= <that>x</that> | |
val thatcr= Seq(that,Text("\n")) | |
val xml= <root> | |
{ for (x<-1 to 4) yield that } | |
{ for (x<-1 to 4) yield |
This file contains 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
xquery version "1.0-ml"; | |
let $out:=sem:sparql(' | |
SELECT * | |
WHERE { <http://dbpedia.org/resource/Debbie_Harry> ?p ?o } | |
') | |
for $i in $out | |
let $p:=map:get($i,"p") | |
let $o:=map:get($i,"o") |
This file contains 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 Rational extends App { | |
case class Rational(n: Int, d: Int=1) extends Ordered[Rational]{ | |
require(d != 0) | |
private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b) | |
private val g = gcd(n.abs, d.abs) | |
val numer = n / g | |
val denom = d / g | |
def + (that: Rational) = Rational( numer * that.denom + that.numer * denom, denom * that.denom) |
This file contains 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 akka.actor.ActorSystem | |
import scala.concurrent.duration._ | |
import akka.actor.ActorDSL._ | |
object ThrottledProcessor extends App { | |
implicit val system = ActorSystem("ThrottledProcessor") | |
import system.dispatcher | |
case object Dump | |
case object Process |
OlderNewer