Skip to content

Instantly share code, notes, and snippets.

View nacnudus's full-sized avatar

Duncan Garmonsway nacnudus

View GitHub Profile
@nacnudus
nacnudus / as.list.hashtab.R
Created May 31, 2022 14:45
Inspect a nested hashtab as a list
# Inspect a nested hash table as a list
as.list.hashtab <- function(h) {
val <- vector("list", 0)
maphash(h, function(k, v) {
r <- if (is.hashtab(v)) {
as.list.hashtab(v)
}else {
v
}
val[[k]] <<- r
graph LR
    A[N: config<br/>N: state<br/>N: reality] -->|Nothing to do| B(N: config<br/>N: state<br/>N: reality)
    C[Y: config<br/>N: state<br/>N: reality] -->|Create| D(Y: config<br/>Y: state<br/>Y: reality)
    E[N: config<br/>Y: state<br/>N: reality] -->|Someone manually deleted it,<br/>and also removed it from the config.| F(?)
    G[N: config<br/>N: state<br/>Y: reality] -->|Ignore| H(N: config<br/>N: state<br/>Y: reality)
    I[Y: config<br/>Y: state<br/>N: reality] -->|Recreate?<br/>Someone manually deleted it.| D
    K[Y: config<br/>N: state<br/>Y: reality] -->|Error. You must import the existing resource into the state.| D
    M[N: config<br/>Y: state<br/>Y: reality] -->|Delete| N(N: config<br/>N: state<br/>N: reality)
 O[Y: configY: stateY: reality] --&gt;|Nothing to do| P(Y: configY: stateY: reality)