Skip to content

Instantly share code, notes, and snippets.

t1: Time = 1:23
t2: Time = 1:55
t3: Time = 1:55
t4: Time = 1:56
t5: Time = 2:4
t1: 1:23, t2: 1:55, before: true
t1: 1:55, t2: 1:23, before: false
t1: 1:23, t2: 1:55, before: true
t1: 1:55, t2: 1:23, before: false
t1: 1:23, t2: 1:56, before: true
class Time(val hours: Int, val minutes: Int) {
def before(other: Time): Boolean = {
hours < other.hours ||
(hours == other.hours && minutes < other.minutes)
}
def check(other: Time): Unit = {
printf("t1: %s, t2: %s, before: %s\n", this, other, this.before(other))
}
override def toString = "" + hours + ":" + minutes
}
/**
git clone https://github.com/twitter/scalding.git
cd scalding
./sbt scalding-repl/console
*/
import scala.io.Source
val alice = Source.fromURL("http://www.gutenberg.org/files/11/11.txt").getLines
// Add the line numbers, which we might want later
val aliceLineNum = alice.zipWithIndex.toList