Skip to content

Instantly share code, notes, and snippets.

Avatar

Cedric Beust cbeust

View GitHub Profile
View gist:05f0cbb277ca5030b267513758d52395
;CHROME REVENGE by Abaddon
;the DOS 1k intro for Assembly 2020
;code: TomCat
;music: ern0
maxvol EQU 0
times EQU 0
Divider EQU 68
View gist:e80d5d8109ea46813cb4ca4ae93415c7
; Test access to the memory card ($D000 and above).
; This is an adaptation of Zellyn's a2audit tests made to be run headlessly: https://github.com/zellyn/a2audit
; If the tests succed, $3D contains the number of successful tests
; If a test fails, the code lands on a BRK, $3D contains the number of passed tests,
; and Y is the index of the comparison that failed (1-5)
;
; Cedric Beust, cedric@beust.com, 9/17/2020
;
D1 := $d17b
View gist:1fadf9f671897b0d5c365f2d48072032
~/kotlin/kobalt $ k assemble
__ __ __ __ __
/ //_/ ____ / /_ ____ _ / / / /_
/ ,< / __ \ / __ \ / __ `/ / / / __/
/ /| | / /_/ / / /_/ // /_/ / / / / /_
/_/ |_| \____/ /_.___/ \__,_/ /_/ \__/ 1.0.93
Regular compilation time: 2459 ms
Parallel build starting
╔═════════════════════════╗
View gist:e6a807e82126b96e3f429e7e3b2ff291
~/kotlin/kobalt $ k assemble
__ __ __ __ __
/ //_/ ____ / /_ ____ _ / / / /_
/ ,< / __ \ / __ \ / __ `/ / / / __/
/ /| | / /_/ / / /_/ // /_/ / / / / /_
/_/ |_| \____/ /_.___/ \__,_/ /_/ \__/ 1.0.93
Regular compilation time: 2459 ms
Parallel build starting
╔═════════════════════════╗
View output.txt
Root
A
A1
A2
A3
B
B1
B2
B21
View a.kt
class Tree(val payload: Int, val leaves: List<Tree>)
View a.kt
displayGraphGeneric(graph, Node::children, Node::value)
displayGraphGeneric(tree, Tree::leaves, Tree::payload)
View a.kt
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 + “ “)
}
}
View a.kt
val graph = listOf(Node(“A”, listOf(
Node(“A1”),
Node(“A2”)))
)
displayGraph(graph)
val tree = listOf(Tree(1, listOf(
Tree(11),
Tree(12)))
)