This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
NewerOlder