Skip to content

Instantly share code, notes, and snippets.

View cbeust's full-sized avatar

Cedric Beust cbeust

View GitHub Profile
$ ./kobaltw test ~/t/wire
__ __ __ __ __
/ //_/ ____ / /_ ____ _ / / / /_
/ ,< / __ \ / __ \ / __ `/ / / / __/
/ /| | / /_/ / / /_/ // /_/ / / / / /_
/_/ |_| \____/ /_.___/ \__,_/ /_/ \__/ 0.407
╔════════════════════════════╗
║ Building wire-gson-support ║
╚════════════════════════════╝
@cbeust
cbeust / gist:87a773d7db29b69f35a7
Created February 5, 2016 22:29
Use this build file and update to 0.503
/*
* This file is part of Material Audiobook Player.
*
* Material Audiobook Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
*
* Material Audiobook Player is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
class Node(val value: String,
val children: List<Node> = emptyList())
fun displayGraph(roots: List<Node>, indent: String = “”) {
roots.forEach {
println(indent + it.value)
displayGraph(it.children, indent + “ “)
}
}
@cbeust
cbeust / a.kt
Created February 7, 2017 20:15
val node = Node(“Root”, listOf(
Node(“A”, listOf(
Node(“A1”),
Node(“A2”),
Node(“A3”))
),
Node(“B”, listOf(
Node(“B1”),
Node(“B2”, listOf(
Node(“B21”),
@cbeust
cbeust / a.kt
Created February 7, 2017 20:16
interface INode<T> {
val children: List<INode<T>>
val value: T
}
@cbeust
cbeust / a.kt
Created February 7, 2017 20:17
fun <T> displayGraph(roots: List<INode<T>>, indent: String = “”) {
roots.forEach {
println(indent + it.value)
displayGraph(it.children, indent + “ “)
}
}
@cbeust
cbeust / a.kt
Created February 7, 2017 20:17
class Node(override val value: String,
override val children: List<Node> = emptyList()) : INode<String>
class Tree(val payload: Int, val leaves: List<Tree>) : INode<Int> {
override val children: List<Tree> = leaves
override val value: Int = payload
}
@cbeust
cbeust / a.kt
Created February 7, 2017 20:17
class Node(override val value: String,
override val children: List<Node> = emptyList()) : INode<String>
class Tree(val payload: Int, val leaves: List<Tree>) : INode<Int> {
override val children: List<Tree> = leaves
override val value: Int = payload
}
@cbeust
cbeust / a.kt
Created February 7, 2017 20:18
val graph = listOf(Node(“A”, listOf(
Node(“A1”),
Node(“A2”)))
)
displayGraph(graph)
val tree = listOf(Tree(1, listOf(
Tree(11),
Tree(12)))
)
@cbeust
cbeust / a.kt
Created February 7, 2017 20:18
fun <T, U> displayGraphGeneric(roots: List<T>,
children: (T) -> List<T>,
value: (T) -> U,
indent: String = “”) {
roots.forEach {
println(indent + value(it))
displayGraphGeneric(children(it), children, value,
indent + “ “)
}
}