diff --git a/kotstd/include/ByteArray.kt b/kotstd/include/ByteArray.kt index 1e439622e66..bca1483879e 100644 --- a/kotstd/include/ByteArray.kt +++ b/kotstd/include/ByteArray.kt @@ -41,12 +41,21 @@ class ByteArray(var size: Int) { } fun ByteArray.print() { - println() var index = 0 + print('[') while (index < size) { - println(get(index)) + print(get(index)) index++ + if (index < size){ + print(';') + print(' ') + } } + print(']') +} + +fun ByteArray.println() { + this.print() println() } diff --git a/kotstd/include/Console.kt b/kotstd/include/Console.kt index fa3cbc15d32..79460bbac62 100644 --- a/kotstd/include/Console.kt +++ b/kotstd/include/Console.kt @@ -70,6 +70,16 @@ fun print(message: String) { kotlinclib_print_string(message) } +/** Prints the given message and newline to the standard output stream. */ +fun print(message: ByteArray) { + message.print() +} + +/** Prints the given message and newline to the standard output stream. */ +fun print(message: IntArray) { + message.print() +} + /** Prints the given message and newline to the standard output stream. */ fun println(message: Int) { @@ -118,7 +128,12 @@ fun println(message: String) { /** Prints the given message and newline to the standard output stream. */ fun println(message: ByteArray) { - message.print() + message.println() +} + +/** Prints the given message and newline to the standard output stream. */ +fun println(message: IntArray) { + message.println() } /** Prints newline to the standard output stream. */ diff --git a/kotstd/include/IntArray.kt b/kotstd/include/IntArray.kt index e2b9d616b44..7003dd63a53 100644 --- a/kotstd/include/IntArray.kt +++ b/kotstd/include/IntArray.kt @@ -39,6 +39,26 @@ class IntArray(var size: Int) { } + +fun IntArray.print() { + var index = 0 + print('[') + while (index < size) { + print(get(index)) + index++ + if (index < size) { + print(';') + print(' ') + } + } + print(']') +} + +fun IntArray.println() { + this.print() + println() +} + fun IntArray.copyOf(newSize: Int): IntArray { val newInstance = IntArray(newSize) var index = 0