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://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 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 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 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 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 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 bootstrap | |
| package liftweb | |
| import net.liftweb.http.LiftRules | |
| import net.liftweb.sitemap.{SiteMap,Menu} | |
| class Boot { | |
| def boot { | |
| LiftRules.addToPackages("code") | |
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
| <!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 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
| <?xml version="1.0" encoding="ISO-8859-1"?> | |
| <!DOCTYPE web-app | |
| PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" | |
| "http://java.sun.com/dtd/web-app_2_3.dtd"> | |
| <web-app> | |
| <filter> | |
| <filter-name>LiftFilter</filter-name> | |
| <display-name>Lift Filter</display-name> |
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 com.typesafe.startscript.StartScriptPlugin | |
| name := "Lift Hello World" | |
| seq(StartScriptPlugin.startScriptForClassesSettings: _*) | |
| libraryDependencies ++= { | |
| Seq( | |
| "org.eclipse.jetty" % "jetty-server" % "7.5.4.v20111024" % "compile->default", | |
| "org.eclipse.jetty" % "jetty-servlet" % "7.5.4.v20111024" % "compile->default", |
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://projecteuler.net/problem=1 | |
| // If we list all the natural numbers below 10 that are multiples of 3 or 5, | |
| // we get 3, 5, 6 and 9. The sum of these multiples is 23. | |
| // Find the sum of all the multiples of 3 or 5 below 1000. | |
| object Problem01 { | |
| def main(args: Array[String]) { | |
| val output = "Sum of [3,5] multiples below %d: " |
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://projecteuler.net/problem=2 | |
| // Each new term in the Fibonacci sequence is generated by adding the previous two terms. | |
| // By starting with 1 and 2, the first 10 terms will be: | |
| // 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... | |
| // By considering the terms in the Fibonacci sequence whose values do not exceed four million, | |
| // find the sum of the even-valued terms. |
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://projecteuler.net/problem=3 | |
| //The prime factors of 13195 are 5, 7, 13 and 29. | |
| //What is the largest prime factor of the number 600851475143 ? | |
| object Problem03 { | |
| def main(args: Array[String]) { | |
| //val number = 13195 | |
| val number = 600851475143L |