This file contains 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
object DSL { | |
implicit def MkDSLRichAnyOps[T](elem: T) = | |
new DSLRichAny(elem) | |
} |
This file contains 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 scalation | |
package advmath | |
object Vec { | |
} | |
class Vec [A: Numeric] extends VecLike[A, Vec[A]] { | |
} |
This file contains 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
object ExponentiationApp extends App with ScalaTion | |
{ | |
val exp1 = 2 ↑ 2 // 4 | |
val exp2 = 2 ↑ 2 ↑ 2 // 16 | |
println("2↑2 = %s".format(exp1)) | |
println("2↑2↑2 = %s".format(exp2)) | |
} |
This file contains 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 MyNum (val d: Double) extends Numeric [MyNum] | |
{ | |
def fromInt (n: Int) = MyNum (n) | |
def + (rhs: MyNum) = plus(this, rhs) | |
def plus (x: MyNum, y: MyNum): MyNum = MyNum (x.d + y.d) | |
def minus (x: MyNum, y: MyNum): MyNum = MyNum (x.d - y.d) | |
def times (x: MyNum, y: MyNum): MyNum = MyNum (x.d * y.d) | |
def negate (x: MyNum): MyNum = MyNum (-x.d) | |
def toInt (x: MyNum): Int = x.d.toInt | |
def toLong (x: MyNum): Long = x.d.toLong |
This file contains 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
object Combo extends App { | |
val vars = List("a", "b", "c", "d") | |
val list = vars map (e => ("-%s".format(e), "+%s".format(e))) | |
val len = list.size | |
val combos = math.pow(2, len).toInt | |
for (i <- 0 until combos) { | |
for (j <- 0 until len) { | |
val (off, on) = list(j) | |
print ("%s ".format(if ((i >> j) % 2 == 0) off else on)) |
This file contains 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
:Albert_Einstein :hasAcademicAdvisor :Alfred_Kleiner . |
This file contains 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
object Parens extends App { | |
def balanced (input: String): Boolean = { | |
val stack = collection.mutable.Stack.empty[String] | |
import stack._ | |
for (i <- input) i match { | |
case '(' => push("(") | |
case '[' => push("[") | |
case ')' => if (isEmpty) return false else if (pop() != "(") return false | |
case ']' => if (isEmpty) return false else if (pop() != "[") return false |
This file contains 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
google.load('visualization', '1', {'packages': ['geochart']}); | |
google.setOnLoadCallback(drawMarkersMap); | |
function drawMarkersMap() { | |
var data = new google.visualization.DataTable(); | |
data.addColumn('string', 'City'); | |
data.addColumn('number', 'Population'); | |
data.addColumn('number', 'Area'); | |
data.addRows([ | |
['Rome', 2761477, 1285.31], |
This file contains 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://johnson.cs.uga.edu/triplify/index.php/actor> <http://www.w3.org/2000/01/rdf-schema#comment> "Generated by Triplify V0.7.1 (http://Triplify.org)" . | |
<http://johnson.cs.uga.edu/triplify/index.php/actor> <http://creativecommons.org/ns#license> <http://creativecommons.org/licenses/by/3.0/us/> . | |
<http://johnson.cs.uga.edu/triplify/index.php/actor/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/Actor> . | |
<http://johnson.cs.uga.edu/triplify/index.php/actor/2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/Actor> . | |
<http://johnson.cs.uga.edu/triplify/index.php/actor/3> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/Actor> . | |
<http://johnson.cs.uga.edu/triplify/index.php/actor/4> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/Actor> . | |
<http://johnson.cs.uga.edu/triplify/index.php/actor/5> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/Actor> . | |
<http://jo |
This file contains 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
// NOT TESTED YET | |
import scala.reflect.runtime.universe._ | |
class Schema[T : TypeTag](val attributes: String*) extends Dynamic { | |
val length = attributes.length | |
def selectDynamic[A: TypeTag](field: String): A.tpe = null | |
def updateDynamic[A: TypeTag](field: String)(value: A.tpe) { } | |
} // Schema |
OlderNewer