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
Kingdom | Dynasty | DurIndex | Name | StartDate | EndDate | Duration | |
---|---|---|---|---|---|---|---|
Pre Dynastic | Lower Egypt | 1 | Hsekiu|Seka | 0 | 0 | 0 | |
Pre Dynastic | Lower Egypt | 2 | Khayu | 0 | 0 | 0 | |
Pre Dynastic | Lower Egypt | 3 | Tiu (pharaoh)|Tiu|Teyew | 0 | 0 | 0 | |
Pre Dynastic | Lower Egypt | 4 | Thesh|Tjesh | 0 | 0 | 0 | |
Pre Dynastic | Lower Egypt | 5 | Neheb | 0 | 0 | 0 | |
Pre Dynastic | Lower Egypt | 6 | Wazner | 0 | 0 | 0 | |
Pre Dynastic | Lower Egypt | 7 | Mekh | 0 | 0 | 0 | |
Pre Dynastic | Lower Egypt | 8 | (destroyed) | 0 | 0 | 0 | |
Pre Dynastic | Lower Egypt | 9 | Double Falcon | 0 | 0 | 0 |
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 scala.swing | |
import javax.swing._ | |
object Button { | |
def apply(text0: String)(op: => Unit) = new Button(Action(text0)(op)) | |
} | |
/** | |
* A button that can be clicked, usually to perform some action. |
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 org.lsug.csvswing | |
import swing._ | |
import Swing._ | |
import scala.swing.event.ButtonClicked | |
import java.io.File | |
import scala.util.{Failure, Success, Try} | |
import javax.swing.UIManager | |
object CSVSwing extends SimpleSwingApplication { |
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 lsug | |
import java.security.MessageDigest | |
import java.io.{BufferedInputStream, FileInputStream} | |
object SchemaString extends App { | |
implicit class SchemaHelper(val sc: StringContext) extends AnyVal { | |
def schema(a: Any*): String = sc.parts.head.split('\n').map( _.trim).mkString("\n") |
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 lsug | |
import scala.language.experimental.macros | |
import scala.reflect.macros.Context | |
object Debug { | |
def error(s:String) = macro error_impl | |
def error_impl(c: Context)(s: c.Expr[String]): c.Expr[Unit] = { |
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
Call-by-name vs call-by-value | |
1) Write a timer function, so this will work | |
scala> def sleep( n:Int) { Thread.sleep(n) } | |
scala> timer( sleep(5000) ) | |
scala> Time 5 secs | |
2) Given | |
scala> def dTrue = { Thread.sleep(5000); true } | |
scala> def dFalse = { Thread.sleep(3000); false } |
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
/* | |
* scalac -language:experimental.macros Macros2.scala | |
* scalac -language:experimental.macros Test.scala | |
* scala Test | |
*/ | |
import scala.reflect.makro.Context | |
import language.experimental.macros |
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
http://codekata.pragprog.com/2007/01/kata_four_data_.html | |
Part One: Weather Data | |
scala> Source.fromFile("weather.dat").getLines.map( """\s+([0-9]+)""".r.findAllIn(_).toList).filter( _.length > 3 ).map( x => ( x(0).trim.toInt, x(1).trim.toInt - x(2).trim.toInt)).toList.sortBy( _._2 ).last | |
res51: (Int, Int) = (9,54) | |