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
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta content="text/html; charset=UTF-8" http-equiv="content-type" /> | |
<title>Home</title> | |
</head> | |
<body class="lift:content_id=main"> | |
<div id="main" class="lift:surround?with=default;at=content"> | |
<h2>Welcome to your project!</h2> | |
<p> |
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
package bootstrap | |
package liftweb | |
import net.liftweb.http.LiftRules | |
import net.liftweb.sitemap.{SiteMap,Menu} | |
class Boot { | |
def boot { | |
LiftRules.addToPackages("code") | |
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
package code | |
package snippet | |
import scala.xml.{NodeSeq, Text} | |
import net.liftweb.util._ | |
import net.liftweb.common._ | |
import java.util.Date | |
import Helpers._ | |
class HelloWorld { |
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 org.eclipse.jetty.server.Server | |
import org.eclipse.jetty.servlet.{DefaultServlet, ServletContextHandler} | |
import org.eclipse.jetty.server.nio.SelectChannelConnector | |
import net.liftweb.http.LiftFilter | |
object JettyLauncher extends App { | |
// Slightly modified from | |
// https://github.com/ghostm/lift_blank_heroku | |
// to change Application to App | |
// Original version was modified based on the |
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
// http://aperiodic.net/phil/scala/s-99/ | |
// P10 (*) Run-length encoding of a list. | |
// Use the result of problem P09 to implement the so-called run-length encoding data compression method. Consecutive duplicates of elements are encoded as tuples (N, E) where N is the number of duplicates of the element E. | |
// Example: | |
// scala> encode(List('a, 'a, 'a, 'a, 'b, 'c, 'c, 'a, 'a, 'd, 'e, 'e, 'e, 'e)) | |
// res0: List[(Int, Symbol)] = List((4,'a), (1,'b), (2,'c), (2,'a), (1,'d), (4,'e)) | |
import Problem09.pack |
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
// http://aperiodic.net/phil/scala/s-99/ | |
// P09 (**) Pack consecutive duplicates of list elements into sublists. | |
// If a list contains repeated elements they should be placed in separate sublists. | |
// Example: | |
// scala> pack(List('a, 'a, 'a, 'a, 'b, 'c, 'c, 'a, 'a, 'd, 'e, 'e, 'e, 'e)) | |
// res0: List[List[Symbol]] = List(List('a, 'a, 'a, 'a), List('b), List('c, 'c), List('a, 'a), List('d), List('e, 'e, 'e, 'e)) | |
object Problem09 { |
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
// http://aperiodic.net/phil/scala/s-99/ | |
// P08 (**) Eliminate consecutive duplicates of list elements. | |
// If a list contains repeated elements they should be replaced with a single copy of the element. The order of the elements should not be changed. | |
// Example: | |
// scala> compress(List('a, 'a, 'a, 'a, 'b, 'c, 'c, 'a, 'a, 'd, 'e, 'e, 'e, 'e)) | |
// res0: List[Symbol] = List('a, 'b, 'c, 'a, 'd, 'e) | |
object Problem08 { |
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
// http://aperiodic.net/phil/scala/s-99/ | |
// P07 (**) Flatten a nested list structure. | |
// Example: | |
// scala> flatten(List(List(1, 1), 2, List(3, List(5, 8)))) | |
// res0: List[Any] = List(1, 1, 2, 3, 5, 8) | |
object Problem07 { | |
def main(args: Array[String]) { | |
val values = List(List(1, 1), 2, List(3, List(5, 8))) |
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
// http://aperiodic.net/phil/scala/s-99/ | |
// P06 (*) Find out whether a list is a palindrome. | |
// Example: | |
// scala> isPalindrome(List(1, 2, 3, 2, 1)) | |
// res0: Boolean = true | |
object Problem06 { | |
def main(args: Array[String]) { | |
val values = List(1, 2, 3, 2, 1) |
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
// From: http://aperiodic.net/phil/scala/s-99/ | |
// P05 (*) Reverse a list. | |
// Example: | |
// scala> reverse(List(1, 1, 2, 3, 5, 8)) | |
// res0: List[Int] = List(8, 5, 3, 2, 1, 1) | |
object Problem05 { | |
def main(args: Array[String]) { | |
val values = List(1, 1, 2, 3, 5, 8) |