diff --git a/kotstd/include/BooleanArray.kt b/kotstd/include/BooleanArray.kt index e5c85c56b43..3d7f72770f7 100644 --- a/kotstd/include/BooleanArray.kt +++ b/kotstd/include/BooleanArray.kt @@ -46,6 +46,26 @@ class BooleanArray(var size: Int) { } +fun BooleanArray.print() { + var index = 0 + print('[') + while (index < size) { + print(get(index)) + index++ + if (index < size){ + print(';') + print(' ') + } + } + print(']') +} + +fun BooleanArray.println() { + this.print() + println() +} + + fun BooleanArray.copyOf(newSize: Int): BooleanArray { val newInstance = BooleanArray(newSize) var index = 0 diff --git a/kotstd/include/Console.kt b/kotstd/include/Console.kt index 79460bbac62..d06919b0fb1 100644 --- a/kotstd/include/Console.kt +++ b/kotstd/include/Console.kt @@ -75,6 +75,11 @@ fun print(message: ByteArray) { message.print() } +/** Prints the given message and newline to the standard output stream. */ +fun print(message: BooleanArray) { + message.print() +} + /** Prints the given message and newline to the standard output stream. */ fun print(message: IntArray) { message.print() @@ -131,6 +136,11 @@ fun println(message: ByteArray) { message.println() } +/** Prints the given message and newline to the standard output stream. */ +fun println(message: BooleanArray) { + message.println() +} + /** Prints the given message and newline to the standard output stream. */ fun println(message: IntArray) { message.println() diff --git a/translator/src/test/kotlin/tests/kotlin/booleanarray_1.kt b/translator/src/test/kotlin/tests/kotlin/booleanarray_1.kt index 4934d1c7afe..b05d0a9e391 100644 --- a/translator/src/test/kotlin/tests/kotlin/booleanarray_1.kt +++ b/translator/src/test/kotlin/tests/kotlin/booleanarray_1.kt @@ -1,5 +1,10 @@ -fun booleanarray_1(x: Boolean): Boolean { +fun booleanarray_1_slave(x: Boolean): Boolean { val z = BooleanArray(10) z.set(1, x) return z.get(1) -} \ No newline at end of file +} + +fun booleanarray_1(x: Boolean): Int { + return if (booleanarray_1_slave(x)) 1 else 0 +} +