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 scala.annotation.tailrec | |
object Main { | |
def main(args: Array[String]) { | |
println("prim") | |
prim(sampleGraph).sortBy(_.weight).foreach(println) | |
println("kruskal") | |
kruskal(sampleGraph).sortBy(_.weight).foreach(println) | |
} |
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 Main { | |
def main(args: Array[String]) { | |
val l = Seq(3,1,5,3,2) | |
val range = l.max + 1 | |
println(countingSort(l, range)) | |
println(bucketSort(l, range)) | |
sleepSort(l) | |
} | |
// 数え上げソート |
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
for cid in $(git branch -av | grep -v "> origin" | awk '{print $2}'); do; git show --pretty="%ct@%cn@%s" $cid | head -1; done | sort | gawk -F "@" '{print strftime("%c", $1) " : " $2 " : " $3}' |
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
gulp = require('gulp') | |
coffee = require('gulp-coffee') | |
stylus = require('gulp-stylus') | |
nib = require('nib') | |
livereload = require('gulp-livereload') | |
wait = require('gulp-wait') | |
paths = | |
coffee: | |
in : ['js/**/*'] |
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
gulp = require('gulp') | |
fileinclude = require('gulp-file-include') | |
coffee = require('gulp-coffee') | |
runSequence = require('run-sequence') | |
app = 'app' | |
paths = | |
fileinclude: | |
in : ["#{app}/**/*.coffee", "!#{app}/.tmp"] |
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 interval2seq(in: Interval): Seq[DateTime] = { | |
@tailrec | |
def f(t: DateTime, acum: Seq[DateTime]): Seq[DateTime] = if (in.contains(t)) f(d.plusDay(1), t +: acum) else acum.reverse | |
f(in.start, Nil) | |
} |
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
"foo" -> mapping( | |
"msg" -> text.transform[String](toLF, identity) | |
)(Foo.apply)(Foo.unapply) | |
def toLF(a: String): String = a.replaceAll("(\r\n|\r)","\n") |
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
trait Foo[T] { | |
def bar(list: Seq[T]): Unit | |
} | |
object Foo { | |
def bar[T: Foo](list: Seq[T]): Unit = implicitly[Foo[T]].bar(list) | |
implicit val FooInt = new Foo[Int] { | |
def bar(list: Seq[Int]): Unit = println("Int " + list) | |
} | |
implicit val FooDouble = new Foo[Double] { |
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
scala> def sleep = { Thread.sleep(2000); println("done"); 1 } | |
sleep: Int | |
scala> for { a <- Future(sleep); b <- Future(sleep) } yield { println(a + b) } | |
res19: scala.concurrent.Future[Unit] = scala.concurrent.impl.Promise$DefaultPromise@52621501 | |
scala> done | |
done | |
2 |
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
scala> class Person | |
defined class Person | |
scala> class Bob extends Person | |
defined class Bob | |
scala> class Alice extends Person | |
defined class Alice | |
scala> class School[+A] |