Skip to content

Instantly share code, notes, and snippets.

class Poly(coeffs: Int => Double) {
// Memoizing coefficient accessor. Returns the coefficient for x^n.
def apply(n: Int): Double = memo.getOrElseUpdate(n, this.coeffs(n))
// The memo table
private val memo = scala.collection.mutable.HashMap[Int, Double]()
def +(that: Poly): Poly = new Poly(n => this(n) + that(n))
object Injection {
// A table of constant 0 functions
def zeroes: Int => (Int => Int) = (n1: Int) => (n2: Int) => 0
// Update an entry in a function table with a new function at the given position.
def update(t: Int => (Int => Int), k: Int, f: Int => Int): Int => (Int => Int) = {
(n: Int) => if (n == k) f else t(n)
}
def diag(hinv: Int => (Int => Int)): Int => Int = {
class !<:<[A, B]
implicit def any[A, B]: A !<:< B = new !<:<[A, B]
implicit def sub1[A, B >: A]: A !<:< B = new !<:<[A, B]
implicit def sub2[A, B >: A]: A !<:< B = new !<:<[A, B]
sealed trait ShardKeyNotSpecified
sealed trait ShardAware
trait Sharded
sealed trait Limited
sealed trait Unlimited
sealed trait Lim extends Limited with Unlimited
sealed trait Skipped
sealed trait Unskipped
sealed trait Sk extends Skipped with Unskipped
sealed trait Selected
sealed trait Unselected
class !<:<[A, B]
implicit def any[A, B]: A !<:< B = new !<:<[A, B]
implicit def sub1[A, B >: A]: A !<:< B = new !<:<[A, B]
implicit def sub2[A, B >: A]: A !<:< B = new !<:<[A, B]
abstract class Tag
abstract class Unlimited
abstract class Unselected
abstract class Unskipped
class JavaEmbeddedRecord<UserId extends Long> {
public UserId getId() {
return (UserId)(new Long(5));
}
}
import scala.collection.mutable.WrappedArray
abstract class Impl(val name: String) {
val N = 20000
val R = 100
def setup(n: Int): Unit = ()
def run(n: Int): Unit