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
/** | |
* In reply to http://blog.xebia.com/2009/07/04/real-world-functional-programming-in-scala-comparing-java-clojure-and-scala/ | |
*/ | |
def opt[T](x: Seq[T]): Seq[T] = if (x == null) Nil else x | |
def indexed[T](coll: Seq[T]): Seq[(Int, T)] = { | |
val c = opt(coll) | |
List.range(0,c.length).zip(c.toList) | |
} |
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
/* | |
* IfLoggedIn implementation which redirects to the page a user was going to, | |
* after his/her successful login | |
* | |
* based on http://groups.google.com/group/liftweb/browse_thread/thread/bdd5accd4bb623c9/d56e054c4037470f , | |
* works with ProtoUser out of the box | |
*/ | |
// In SiteMap: | |
lazy val IfLoggedIn = If(User.loggedIn_? _, loginAndComeBack _) |
NewerOlder