- (2 points) Easy: What is the difference beteen var, val and def? [x] 2
- (3 points) Easy: How does pattern matching work in Scala? [x] 3
- (3 points) Easy: What are right associative methods in Scala? [x] 0
- (3 points) Easy: What is the difference between a trait and an abstract class in Scala? [x] 3
- (2 points) Medium: What is scala.util.control.NonFatal? [x] 2
- (3 points) Medium: How does Scala solve the diamond resolution problem with traits? [x] 3
Using Scala and a parser combinator library of your choice, please spend 3 hours on:
Every large software project has its share of configuration files to control settings, execution, etc. Let’s contemplate a config file format that looks a lot like standard PHP .ini files, but with a few tweaks.
A config file will appear as follows:
[common]
package code.lib; | |
import net.liftweb.http.rest.RestHelper | |
import net.liftweb.http.{ LiftRules, LiftResponse, Req, UnauthorizedResponse } | |
import net.liftweb.common.{ Box, Full, Empty, Failure, ParamFailure } | |
trait TypesHelper { | |
implicit def pfAuthorize[A, B](in: PartialFunction[A, B]): OAuthPartialFunctionWrapper[A, B] = | |
new OAuthPartialFunctionWrapper[A, B](in) | |
} |
package com.example.record | |
/** | |
* In here you will learn how to define a basic MongoDB record class. | |
* It's type safe and far more powerful than anything our there. | |
* First, a few basic imports | |
*/ | |
import org.bson.types.ObjectId | |
import org.joda.time.DateTime |
import net.liftweb.http.rest.{ RestContinuation, RestHelper } | |
import net.liftweb.http.{ NotAcceptableResponse, OkResponse, S, UnauthorizedResponse } | |
import net.liftweb.json.{ DefaultFormats, JsonAST, JsonParser } | |
import net.liftweb.json.JsonAst.JValue; | |
/** | |
* This is a trivial implementation of a Scala case class. | |
* In our code, they are companions to more complex database models. | |
*/ |
package whatever; | |
import java.util.{ List => JList, Map => JMap } | |
import com.foursquare.rogue.LiftRogue._ | |
import com.foursquare.rogue.{ | |
AbstractQueryField, | |
AbstractModifyField, | |
EqClause, | |
ModifyClause, | |
ModOps, |
package org.projecteuler.exercises | |
import scala.annotation.tailrec; | |
import scala.collection.mutable.HashMap; | |
object LargestCollatzSeq { | |
val map: HashMap[BigInt, BigInt] = new HashMap | |
val limit = 1000000 |
public class Pair { | |
private String left; | |
private String right; | |
public Pair(String v1, String v2) { | |
left = v1; | |
right = v2; | |
}; | |
public String getLeft() { |
Here's some free debugging as we all really need the service back up and running properly. Cookies and cache where completely wipped before attempting the exercise, several times. The error is consistent across operating systems, devices, browsers and even machines.
At line 356 of LoginLink.action
you are passing empty constructor arguments to a JavaScript class instantiation potentially due to a server side error failing to output the relevant arguments where they should be.
The code ends up being:
var timeout = new LoginTimeout( , );
lazy val service2Thrift = Project( | |
id = "service2-thrift", | |
base = file("service2-thrift"), | |
settings = Project.defaultSettings ++ | |
VersionManagement.newSettings ++ | |
sharedSettings ++ | |
ScroogeSBT.newSettings ++ | |
publishSettings | |
).settings( |