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 org.jscience.physics.amount.* | |
def a = Amount.valueOf("1 m") | |
def b = Amount.valueOf("2 m") | |
Amount.metaClass.negative { | |
opposite() | |
} | |
def c = a + -b |
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
@GrabResolver(name='jsciencerepos', root='http://maven.obiba.org/maven2/') | |
@Grab('org.jscience:jscience:4.3.1') | |
import javax.measure.quantity.Quantity | |
import javax.measure.unit.ProductUnit | |
import javax.measure.unit.Unit | |
import org.jscience.physics.amount.Amount | |
import static javax.measure.unit.SI.* |
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
@GrabResolver(name='jsciencerepos', root='http://maven.obiba.org/maven2/') | |
@Grab('org.jscience:jscience:4.3.1') | |
import org.jscience.physics.amount.Amount | |
q = Amount.valueOf("1.0 kW") | |
dt = Amount.valueOf("1.0 K") | |
cp = q.divide(dt) | |
//assert Amount.valueOf("1.0 kW/K") != cp // なんかおかしい |
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
@GrabResolver(name='jsciencerepos', root='http://maven.obiba.org/maven2/') | |
@Grab('org.jscience:jscience:4.3.1') | |
import javax.measure.quantity.* | |
import org.jscience.physics.amount.Amount | |
a = Amount.valueOf("1 m") | |
b = Amount.valueOf("1 m") | |
Amount<Mass> c = (a + b).to(Length.UNIT) // 正しくは Amount<Length> |
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 javax.measure.Measurable | |
import javax.measure.quantity.Quantity | |
import javax.measure.unit.Unit | |
// 任意の型からMeasurable[Q]を作る…前にargにMeasurable[Q]が渡されたときを考える。 | |
def toMeasurable[Q <: Quantity](arg: Any)(implicit manifest: ClassManifest[Q]): Measurable[Q] = { | |
arg match { | |
case measurable: Measurable[_] => | |
try { | |
// measurable の型パラメータが正しいことを保証するために |
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
var simulationCase = WScript.GetObject("C:/Program Files/AspenTech/Aspen HYSYS 2006.5/Samples/TUTOR1.hsc"); | |
// 全ての単位操作の名前を書き出す | |
for (var index = 0; index < simulationCase.Flowsheet.Operations.Count; index++) { | |
var operation = simulationCase.Flowsheet.Operations.Item(index); | |
WScript.Echo(operation.name); | |
} | |
// 参考 | |
// C:/Program Files/AspenTech/Aspen HYSYS 2006.5/xhysys.chm |
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
// Scala でパターンマッチしてる部分を、Clojure のマルチメソッドっぽく書きたいなぁ、と。つまり、 | |
// def hoge2fuga(hoge: Hoge) = { | |
// hoge match { | |
// case Hoge1 => | |
// fuga1 | |
// case Hoge2 => | |
// fuga2 | |
// } | |
// } |
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 ReturnFromAnonymousFunction { | |
def main(args: Array[String]) { | |
println(hoge()) | |
} | |
def hoge: () => Seq[Int] = { | |
() => | |
(1 to 10).map { | |
i => | |
if(i < 5) |
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
// g100pon #18 単位換算 | |
// JScience を使用します - http://jscience.org/ | |
// 注: 次期バージョン(5.0)では配布方法が変わるため、以下の Grab 指定が変わる可能性があります。 | |
// また、本バージョン(4.x)も、公式には Maven リポジトリとして配布されていません。 | |
// 現在は以下に示すサイトで暫定的に取得できます。 | |
//@GrabResolver(name = 'jcurl', root = 'http://www.jcurl.org/m2/repo/') | |
//@GrabResolver(name = 'obiba', root = 'http://maven.obiba.org/maven2/') | |
@Grab('org.jscience:jscience:4.3.1') | |
import javax.measure.DecimalMeasure |
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 p | |
class RichString(str: String) { | |
def test = { | |
m(str) | |
} | |
} | |
// 追記 | |
// RichString をどこか別のパッケージ(たとえば p2)にして |
OlderNewer