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
.DS_Store | |
logs/ | |
data/ | |
*.html |
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
import controllers.{routes, Application} | |
import play.api._ | |
import play.api.mvc._ | |
import play.api.mvc.Results._ | |
import play.api.Play.current | |
import controllers.Utils._ | |
object Global extends GlobalSettings { | |
override def onRouteRequest(request: RequestHeader): Option[Handler] = { |
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
name := "coderetreat-trivia" | |
version := "0.0.1" | |
organization := "org.purang.net" | |
scalaVersion := "2.9.1" | |
libraryDependencies ++= Seq( | |
"org.scalaz" % "scalaz-core_2.9.1" % "6.0.3" withSources(), |
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
:silent | |
//the following are helper functions | |
def p = if(readLine() == "q") sys.exit | |
def pp[A]: ( => A) => Unit = a => {readLine() ; a} | |
object > { | |
def > : String => Unit = println _ | |
def >[A] : (String, => A) => Unit = (a,b) => {print("> " + a); readLine(); readLine(); println(" ----> " + b); println} | |
} |
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
val add = """.*: what is (\d*) plus (\d*)""".r | |
q match { | |
case add(a, b) =>(a.toInt + b.toInt).toString | |
case bond() => // well we don't want to reveal too much | |
case banana() => //but bond and banana ought to get the attention. | |
case _ => "" | |
} |
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
-- import Control.Monad (ap) | |
type Pos = (Int, Int) | |
type Direction = Pos -> Pos | |
direction :: Pos -> [Direction] -> [Pos] | |
direction p [] = [] | |
direction p (x:xs) = x p : direction p xs | |
-- another way | |
-- direction p ds = ap ds [p] |
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
#!/bin/sh | |
L=`dirname $0`/../lib | |
cp=`echo $L/*.jar|sed 's/ /:/g'` | |
exec scala -classpath $cp -savecompiled $0 $@ | |
!# | |
# shebang magic from http://www.eamonn.org/blog/archives/425 | |
println("hello world") |
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
import sbt._ | |
import Keys._ | |
import sbt.Package._ | |
import java.util.jar.Attributes.Name._ | |
import com.github.siasia.WebPlugin._ | |
//unashamed copy of scalaz's build | |
object SlogBuild extends Build { | |
override lazy val settings = super.settings :+ |
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
//performance is not everything | |
//can this be parallel? | |
def isPalindrome(list: List[Int]) = { | |
(list zip list.reverse filter (a => a._1 != a._2) size) == 0 | |
} |