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 Vect3(x: Double, y: Double, z: Double) { | |
def +(v: Vect3) = Vect3(x+v.x, y+v.y, z+v.z) | |
def -(v: Vect3) = Vect3(x-v.x, y-v.y, z-v.z) | |
def *(c: Double) = Vect3(x*c, y*c, z*c) | |
def /(c: Double) = Vect3(x/c, y/c, z/c) | |
} | |
case class ImmutableBody(p: Vect3, v: Vect3, mass: Double) { | |
def step(a: Vect3, dt: Double) = { | |
val nv = v+a*dt |
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
class MVect3(var x: Double, var y: Double, var z: Double) { | |
def zero(): Unit = { | |
x = 0.0 | |
y = 0.0 | |
z = 0.0 | |
} | |
} | |
class MutableBody( | |
val p: MVect3, |
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 NBodyArray extends App { | |
def timeCode[T](warmups: Int, timeRuns: Int)(body: => T): Seq[Double] = { | |
for(_ <- 1 to warmups) body | |
for(_ <- 1 to timeRuns) yield { | |
val start = System.nanoTime() | |
body | |
(System.nanoTime()-start)*1e-9 | |
} | |
} | |
def printTimeInfo(times: Seq[Double]): Unit = { |
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 grammars | |
import io.StdIn._ | |
/** | |
* @author mlewis | |
*/ | |
object REAddition extends App { | |
val prods1 = Map[String, String]( | |
"N+N1" -> "SN+'NL1", |
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
import io.Source | |
val exportRegex = """.*PIMSDB"."(\S+)".*""".r | |
val exportSource = Source.fromFile("DBExportList.txt") | |
val exportData = (for(exportRegex(fname) <- exportSource.getLines) yield fname.trim).toArray | |
exportSource.close | |
val tableSource = Source.fromFile("TableDefTable.txt") | |
val tableData = tableSource.getLines.map(_.split("\t")(1).trim.toUpperCase).toArray | |
tableSource.close |
NewerOlder