This file contains 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 com.fasterxml.jackson.databind.JsonNode | |
import com.fasterxml.jackson.databind.ObjectMapper | |
val defaultMapper = ObjectMapper() | |
val defaultMapperContext = MapperContext(defaultMapper) | |
class MapperContext(val mapper: ObjectMapper) { | |
inline operator fun <reified T> JsonNode.get(vararg params: Any): T { | |
var current = this | |
for (param in params) { |
This file contains 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
package inlineEnumSet | |
import java.util.EnumSet | |
inline class InlineEnumSet<T : Enum<T>>(val set: UInt) { | |
companion object | |
} | |
//bit extraction functions |
This file contains 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 java.lang.IllegalStateException | |
fun main() { | |
node(5) { | |
left(3) { | |
left(2) { | |
left(3) | |
right(6) | |
} | |
} |
This file contains 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.script.ScriptEngine | |
import javax.script.ScriptEngineManager | |
import kotlin.reflect.KProperty | |
fun main(args: Array<String>) { | |
with(ScriptEngineManager().getEngineByExtension("kts")) { | |
// val x by value { 3 } | |
// println(x) | |
// val x = value("x", 3) |
This file contains 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
fun main() { | |
println(listOf(1, 2, 2).permutations()) | |
println(listOf(1, 2, 2).permutationsFromScala()) | |
println(listOf(1, 2, 2).permutationsFromScala(distinct = true)) | |
} | |
fun <T> Collection<T>.permutations(): List<List<T>> = when (size) { | |
0 -> emptyList() | |
1 -> listOf(listOf(first())) | |
else -> flatMapIndexed { i, x -> |