dbl -> toDouble

This commit is contained in:
Alex Tkachman
2012-02-22 13:14:41 +02:00
parent 18990e2c1b
commit 53bba59a4f
79 changed files with 335 additions and 298 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ class Point(val x: Int, val y: Int) {
fun distanceTo(other: Point): Double {
val dx = x - other.x
val dy = y - other.y
return Math.sqrt((dx*dx + dy*dy).double)
return Math.sqrt((dx*dx + dy*dy).toDouble())
}
}
+1 -1
View File
@@ -167,7 +167,7 @@ abstract class Actor(protected val executor: Executor, val fair: Boolean = false
val messagesSent = AtomicLong()
val messagesProcessed = AtomicLong()
val timer = fixedRateTimer(daemon=true, period=5000.long) {
val timer = fixedRateTimer(daemon=true, period=5000.toLong()) {
val sent = messagesSent.get()
val received = messagesProcessed.get()
println("Actors stat: Sent: $sent Processed: $received Pending: ${sent-received}")
+1 -1
View File
@@ -23,7 +23,7 @@ fun main(args: Array<String>) {
}
for (k in 1..stocksPerClient) {
val stock = (Math.random() * numberOfSymbols).int
val stock = (Math.random() * numberOfSymbols).toInt()
stockServer post Subscribe(stock.toString(), client)
}
}
+4 -4
View File
@@ -7,11 +7,11 @@ import java.util.LinkedList
class StatCalculator() : Actor(Executors.newSingleThreadExecutor().sure()) {
val list = LinkedList<Long> ()
var average = 0.long
var sum = 0.long
var cnt = 0.long
var average = 0.toLong()
var sum = 0.toLong()
var cnt = 0.toLong()
val timer = fixedRateTimer(period=2000.long, daemon=true) {
val timer = fixedRateTimer(period=2000.toLong(), daemon=true) {
this@StatCalculator post "print"
}
+1 -1
View File
@@ -14,7 +14,7 @@ class StockServer(val numberOfShards : Int) : Actor(Executors.newFixedThreadPool
private val shards = Array<StockServerShard> (numberOfShards, { (i: Int) -> StockServerShard(statCalculator, executor) })
private val timer = fixedRateTimer(period=1000.long, daemon=true) {
private val timer = fixedRateTimer(period=1000.toLong(), daemon=true) {
for(s in shards)
s post StockMessage.UpdateModel
}
@@ -37,8 +37,8 @@ fun spectralnormGame(n: Int) : Double {
Approximate (u, v, tmp, r1, r2)
})
var vBv = 0.double
var vv = 0.double;
var vBv = 0.toDouble()
var vv = 0.toDouble();
for (i in 0..nthread-1) {
try {
ap[i].join ();
@@ -100,7 +100,7 @@ class Approximate(val u: DoubleArray, val v: DoubleArray, val _tmp: DoubleArray,
{
for (i in rbegin..rend)
{
var sum = 0.double
var sum = 0.toDouble()
for (j in v.indices)
sum += eval_A (j, i) * v[j];
+94 -59
View File
@@ -58,19 +58,28 @@
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="GuiceDsl.kt" pinned="false" current="true" current-in-tab="true">
<file leaf-file-name="GuiceDsl.kt" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/GuiceDsl.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="31" column="59" selection-start="859" selection-end="859" vertical-scroll-proportion="0.3951613">
<state line="41" column="0" selection-start="1211" selection-end="1211" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Singleton.java" pinned="false" current="false" current-in-tab="false">
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/Singleton.java">
<file leaf-file-name="LinkedBindingBuilder.java" pinned="false" current="false" current-in-tab="false">
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/binder/LinkedBindingBuilder.java">
<provider selected="true" editor-type-id="text-editor">
<state line="32" column="18" selection-start="1107" selection-end="1107" vertical-scroll-proportion="0.0">
<state line="50" column="0" selection-start="1509" selection-end="1509" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="BindingBuilder.java" pinned="false" current="false" current-in-tab="false">
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/internal/BindingBuilder.java">
<provider selected="true" editor-type-id="text-editor">
<state line="129" column="53" selection-start="4384" selection-end="4384" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -121,10 +130,10 @@
</provider>
</entry>
</file>
<file leaf-file-name="GuiceExample.kt" pinned="false" current="false" current-in-tab="false">
<file leaf-file-name="GuiceExample.kt" pinned="false" current="true" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/GuiceExample.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="45" column="87" selection-start="1494" selection-end="1494" vertical-scroll-proportion="0.0">
<state line="31" column="50" selection-start="860" selection-end="860" vertical-scroll-proportion="0.5938967">
<folding />
</state>
</provider>
@@ -158,9 +167,10 @@
</option>
</component>
<component name="ProjectFrameBounds">
<option name="y" value="32" />
<option name="width" value="1429" />
<option name="height" value="790" />
<option name="x" value="1" />
<option name="y" value="22" />
<option name="width" value="1411" />
<option name="height" value="826" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
<OptionsSetting value="true" id="Add" />
@@ -193,6 +203,16 @@
<sortByType />
</navigator>
<panes>
<pane id="Scope">
<subPane subId="Project Files">
<PATH>
<PATH_ELEMENT USER_OBJECT="Root">
<option name="myItemId" value="" />
<option name="myItemType" value="" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="ProjectPane">
<subPane>
<PATH>
@@ -217,16 +237,6 @@
</PATH>
</subPane>
</pane>
<pane id="Scope">
<subPane subId="Project Files">
<PATH>
<PATH_ELEMENT USER_OBJECT="Root">
<option name="myItemId" value="" />
<option name="myItemType" value="" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="PackagesPane">
<subPane>
<PATH>
@@ -496,7 +506,7 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
<frame x="0" y="32" width="1429" height="790" extended-state="0" />
<frame x="1" y="22" width="1411" height="826" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
@@ -505,23 +515,22 @@
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.39886847" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32956153" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Kotlin" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3294714" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="CodeWindow" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.39985326" sideWeight="0.6718529" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32956153" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32956153" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Gradle" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32956153" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.24909486" sideWeight="0.671151" order="0" side_tool="false" content_ui="combo" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.24944974" sideWeight="0.6718529" order="0" side_tool="false" content_ui="combo" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3281471" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="ResolveWindow" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.37655678" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32956153" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="CodeWindow" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.39985326" sideWeight="0.6718529" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32884902" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="ResolveWindow" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.37655678" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="VcsContentAnnotationSettings">
@@ -581,86 +590,112 @@
<option name="FILTER_TARGETS" value="false" />
</component>
<component name="editorHistoryManager">
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/Stage.java">
<provider selected="true" editor-type-id="text-editor">
<state line="23" column="12" selection-start="720" selection-end="720" vertical-scroll-proportion="0.0" />
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/Scope.java">
<provider selected="true" editor-type-id="text-editor">
<state line="16" column="0" selection-start="597" selection-end="597" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/internal/Scoping.java">
<provider selected="true" editor-type-id="text-editor">
<state line="32" column="0" selection-start="1182" selection-end="1182" vertical-scroll-proportion="0.0" />
<state line="32" column="0" selection-start="1182" selection-end="1182" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/binder/AnnotatedBindingBuilder.java">
<provider selected="true" editor-type-id="text-editor">
<state line="25" column="63" selection-start="850" selection-end="850" vertical-scroll-proportion="0.0" />
<state line="25" column="63" selection-start="850" selection-end="850" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/Provider.java">
<provider selected="true" editor-type-id="text-editor">
<state line="44" column="17" selection-start="1946" selection-end="1946" vertical-scroll-proportion="0.0" />
<state line="44" column="17" selection-start="1946" selection-end="1946" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/Binder.java">
<provider selected="true" editor-type-id="text-editor">
<state line="243" column="14" selection-start="11110" selection-end="11110" vertical-scroll-proportion="0.0" />
<state line="243" column="14" selection-start="11110" selection-end="11110" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/binder/LinkedBindingBuilder.java">
<provider selected="true" editor-type-id="text-editor">
<state line="50" column="0" selection-start="1509" selection-end="1509" vertical-scroll-proportion="0.0" />
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/internal/BindingBuilder.java">
<provider selected="true" editor-type-id="text-editor">
<state line="129" column="53" selection-start="4384" selection-end="4384" vertical-scroll-proportion="0.0" />
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/Singleton.java">
<provider selected="true" editor-type-id="text-editor">
<state line="32" column="18" selection-start="1107" selection-end="1107" vertical-scroll-proportion="0.0" />
<state line="50" column="0" selection-start="1509" selection-end="1509" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/spi/InjectionPoint.java">
<provider selected="true" editor-type-id="text-editor">
<state line="374" column="30" selection-start="14896" selection-end="14896" vertical-scroll-proportion="0.0" />
<state line="374" column="30" selection-start="14896" selection-end="14896" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/internal/BindingBuilder.java">
<provider selected="true" editor-type-id="text-editor">
<state line="129" column="53" selection-start="4384" selection-end="4384" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/binder/ScopedBindingBuilder.java">
<provider selected="true" editor-type-id="text-editor">
<state line="31" column="0" selection-start="936" selection-end="936" vertical-scroll-proportion="0.0" />
<state line="31" column="0" selection-start="936" selection-end="936" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/internal/AbstractBindingBuilder.java">
<provider selected="true" editor-type-id="text-editor">
<state line="88" column="34" selection-start="3438" selection-end="3438" vertical-scroll-proportion="0.0" />
<state line="88" column="34" selection-start="3438" selection-end="3438" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/internal/BindingImpl.java">
<provider selected="true" editor-type-id="text-editor">
<state line="99" column="0" selection-start="2736" selection-end="2736" vertical-scroll-proportion="0.0" />
<state line="99" column="0" selection-start="2736" selection-end="2736" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/internal/ProviderInstanceBindingImpl.java">
<provider selected="true" editor-type-id="text-editor">
<state line="79" column="24" selection-start="3009" selection-end="3009" vertical-scroll-proportion="0.0" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/GuiceExample.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="45" column="87" selection-start="1494" selection-end="1494" vertical-scroll-proportion="0.0" />
<state line="79" column="24" selection-start="3009" selection-end="3009" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/lib/guice-3.0-sources.jar!/com/google/inject/Injector.java">
<provider selected="true" editor-type-id="text-editor">
<state line="148" column="0" selection-start="6054" selection-end="6054" vertical-scroll-proportion="0.0" />
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/../../../dist/kotlinc/lib/kotlin-runtime.jar!/std/namespace.class">
<provider selected="true" editor-type-id="text-editor">
<state line="336" column="0" selection-start="40990" selection-end="40990" vertical-scroll-proportion="0.32130584">
<state line="148" column="0" selection-start="6054" selection-end="6054" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/GuiceDsl.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="31" column="59" selection-start="859" selection-end="859" vertical-scroll-proportion="0.3951613">
<state line="41" column="0" selection-start="1211" selection-end="1211" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/GuiceExample.kt">
<provider selected="true" editor-type-id="text-editor">
<state line="31" column="50" selection-start="860" selection-end="860" vertical-scroll-proportion="0.5938967">
<folding />
</state>
</provider>
+1 -1
View File
@@ -92,4 +92,4 @@ class Luhny() {
}
fun Char.isDigit() = Character.isDigit(this)
fun Char.toDigit() = this.int - '0'.int
fun Char.toDigit() = this.toInt() - '0'.toInt()
+3 -3
View File
@@ -144,7 +144,7 @@ fun computeLast(allButLast : String) : Char {
}
var remainder = sum % 10
return if (remainder == 0) '0' else ('0' + (10 - remainder)).char
return if (remainder == 0) '0' else ('0' + (10 - remainder)).toChar()
}
fun computeLast(allButLast : CharSequence) : Char = computeLast(allButLast.toString().sure())
@@ -155,12 +155,12 @@ fun setRandomDigits(builder : StringBuilder, start : Int, end : Int) {
}
/** Generates a random digit. */
fun randomDigit() : Char = ('0' + random.nextInt(10)).char
fun randomDigit() : Char = ('0' + random.nextInt(10)).toChar()
fun nonDigits() : String {
val nonDigits = StringBuilder()
for (i in 0..999)
nonDigits.append((random.nextInt(68) + ':').char)
nonDigits.append((random.nextInt(68) + ':').toChar())
return nonDigits.toString().sure()
}
+3 -3
View File
@@ -63,15 +63,15 @@ var JFrame.title : String
set(t) {setTitle(t)}
var JFrame.size : #(Int, Int)
get() = #(getSize().sure().getWidth().int, getSize().sure().getHeight().int)
get() = #(getSize().sure().getWidth().toInt(), getSize().sure().getHeight().toInt())
set(dim) {setSize(Dimension(dim._1, dim._2))}
var JFrame.height : Int
get() = getSize().sure().getHeight().int
get() = getSize().sure().getHeight().toInt()
set(h) {setSize(width, h)}
var JFrame.width : Int
get() = getSize().sure().getWidth().int
get() = getSize().sure().getWidth().toInt()
set(w) {setSize(height, w)}
var JFrame.defaultCloseOperation : Int