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
| scala> val l = "a" :: "b" :: "c" :: "b" :: "a" :: List() | |
| l: List[java.lang.String] = List(a, b, c, b, a) | |
| scala> val distinct = l.distinct | |
| distinct: List[java.lang.String] = List(a, b, c) | |
| scala> distinct zip (distinct map (p => l.filter(p == _).size)) | |
| res0: List[(java.lang.String, Int)] = List((a,2), (b,2), (c,1)) |
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 java.io.BufferedReader; | |
| import java.io.FileReader; | |
| import java.io.FileWriter; | |
| import java.io.IOException; | |
| import java.io.PrintWriter; | |
| import java.util.*; | |
| public class DuplicateWords { | |
| public static void main(String[] args) { |
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
| case class AcceptHeader(mediaType: String, mediaSubType: String, qualityFactor: Float) |
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.service | |
| import xml.{Elem, Node} | |
| import net.liftweb.http._ | |
| import rest.RestHelper | |
| import provider.HTTPCookie | |
| import net.liftweb.common.{Empty, Full} | |
| import code.model.Product | |
| object WebService extends RestHelper { |
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
| case class NotModifiedResponse(eTag: String) extends LiftResponse with HeaderDefaults { | |
| def toResponse = InMemoryResponse(Array(), "ETag" -> ("\"" + eTag + "\"") :: headers, cookies, 304) | |
| } |
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
| trait RestHelper extends LiftRules.DispatchPF { | |
| ... | |
| /** | |
| * A function that chooses JSON or XML based on the request.. | |
| * Use with serveType | |
| */ | |
| implicit def jxSel(req: Req): Box[JsonXmlSelect] = | |
| if (jsonResponse_?(req)) Full(JsonSelect) | |
| else if (xmlResponse_?(req)) Full(XmlSelect) | |
| else None |
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
| serve { | |
| case "api" :: "user" :: id :: _ Get _ => userDetails(id) | |
| } |