|
package fixtures
|
|
|
|
// Unicode comment: δ½ ε₯½δΈη ππ
|
|
|
|
fun main() {
|
|
// Unicode string literals
|
|
val unicode = "γγγ«γ‘γ―δΈη"
|
|
println(unicode)
|
|
|
|
// Null byte in string
|
|
val nullStr = "hello\u0000world"
|
|
println("Null-str length: ${nullStr.length}")
|
|
|
|
// Deeply nested generics
|
|
val deep = mapOf(
|
|
1 to mapOf(
|
|
2 to mapOf(
|
|
3 to mapOf(
|
|
4 to mapOf(
|
|
5 to "deep"
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
println(deep[1]?.get(2)?.get(3)?.get(4)?.get(5))
|
|
|
|
// Very long string
|
|
val longStr = "x".repeat(10000)
|
|
println("Long string length: ${longStr.length}")
|
|
|
|
// BOM bytes
|
|
val bom = byteArrayOf(0xEF.toByte(), 0xBB.toByte(), 0xBF.toByte(), 'H'.code.toByte(), 'i'.code.toByte())
|
|
println(String(bom))
|
|
|
|
// Deep lambda nesting
|
|
val f1: (Int) -> (Int) -> (Int) -> (Int) -> Int = { x ->
|
|
{ y ->
|
|
{ z ->
|
|
{ w -> x + y + z + w }
|
|
}
|
|
}
|
|
}
|
|
println("Nested lambdas: ${f1(1)(2)(3)(4)}")
|
|
|
|
// Infinite sequence (lazy)
|
|
val naturals = generateSequence(0) { it + 1 }
|
|
println("First 5 naturals: ${naturals.take(5).toList()}")
|
|
|
|
// Deep data class nesting
|
|
data class A(val x: Int)
|
|
data class B(val a: A)
|
|
data class C(val b: B)
|
|
data class D(val c: C)
|
|
data class E(val d: D)
|
|
data class F(val e: E)
|
|
val deepData = F(E(D(C(B(A(42))))))
|
|
println("Deep data: ${deepData.e.d.c.b.a.x}")
|
|
}
|