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 |
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.macros.timestamp | |
import scala.reflect.macros.blackbox.Context | |
import scala.language.experimental.macros | |
object TimestampMacro { | |
def timestampString: String = macro timestampMacro | |
def timestampMacro(c: Context): c.Tree = { | |
import c.universe._ |
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 playpen | |
object CaseMapApp extends App { | |
import caseMapper.CaseMapper._ | |
case class Address(firstLine:String, postcode:String, country:String) | |
case class Person(name: String, age: Int, address:Address) | |
val here=Address("26 Duncoding","KT17 4LX","UK") |
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 es | |
import com.sksamuel.elastic4s.ElasticClient | |
import com.sksamuel.elastic4s.ElasticDsl._ | |
import scala.concurrent._ | |
import ExecutionContext.Implicits.global | |
import scala.concurrent.duration._ | |
object e4s1 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
import akka.actor.ActorSystem | |
import scala.concurrent.duration._ | |
import akka.actor.ActorDSL._ | |
// Better than ThrottledProcessor as it fires immediately if idle, and doesn't send Process messages repeatedly | |
object ThrottledProcessor2 extends App { | |
implicit val system = ActorSystem("ThrottledProcessor") |
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 chroniclemap | |
import net.openhft.chronicle.map._ | |
import java.io.File | |
object C1 extends App { | |
val tmp = System.getProperty("java.io.tmpdir"); | |
val pathname = tmp + "/mychronicle.dat"; |
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
def combine[K,V](map1:Map[K,Seq[V]], map2:Map[K,Seq[V]]) = | |
(map1.toList ++ map2.toList).groupBy(_._1).mapValues(_.map(_._2).flatten).map(identity) |
OlderNewer