Skip to content

Instantly share code, notes, and snippets.

View clhodapp's full-sized avatar

Chris Hodapp clhodapp

  • San Francisco, California
View GitHub Profile
@clhodapp
clhodapp / Dynamic.scala
Created March 28, 2012 04:32
Dynamic example
object Dynamic {
class DynamicBox1(val value: Any) extends Dynamic {
override def applyDyamic[@specialized A](name: String, arg1: A): Dynamic = {
val method = value.getClass.getMethod(name, arg1.getClass)
boxDynamic(method.invoke(value, arg1.asInstanceOf[AnyRef]))
}
override def as[T] = value.asInstanceOf[T]
}
@clhodapp
clhodapp / Ordering.scala
Created February 29, 2012 05:29
Ordering Example
case class A(x: Int)
implicit object AIsOrdered extends Ordering[A] {
def compare(x: A, y: A) = x.x - y.x
}
public Tableau makeArtificial() {
Matrix tmp = getA().mergeRight(Matrix.identity(constraints)).mergeRight(getRHS()); //insert identity
tmp = tmp.mergeDown(new Matrix(1,vars).extend(0,constraints,1d).extend(0,1)); //add new cost row
return new Tableau(tmp);
}
vs
public Tableau makeArtificial() {
Double[][] tmp = new Double[height][width+height-1];