diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-03-19 16:59:30 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-03-19 16:59:30 -0700 |
commit | fddbe08fc896e09d0fec2773977341d72103ff90 (patch) | |
tree | dddd6d116c1acdf7df9a54688ee0cc15a579c6fd /life.tlv | |
parent | 7859317ece5477862e8924657298c3595dd8a8e9 (diff) | |
download | teliva-fddbe08fc896e09d0fec2773977341d72103ff90.tar.gz |
graphviz: for basic stats, show all nodes ordered
The ordering is topological; nodes come before their dependencies. Also some more helpful functions in the template for new apps.
Diffstat (limited to 'life.tlv')
-rw-r--r-- | life.tlv | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/life.tlv b/life.tlv index 4445de8..e35fd59 100644 --- a/life.tlv +++ b/life.tlv @@ -249,6 +249,45 @@ > return result >end - __teliva_timestamp: original + union: + >function union(a, b) + > for k, v in pairs(b) do + > a[k] = v + > end + > return a + >end +- __teliva_timestamp: original + subtract: + >-- set subtraction + >function subtract(a, b) + > for k, v in pairs(b) do + > a[k] = nil + > end + > return a + >end +- __teliva_timestamp: original + all: + >-- universal quantifier on sets + >function all(s, f) + > for k, v in pairs(s) do + > if not f(k, v) then + > return false + > end + > end + > return true + >end +- __teliva_timestamp: original + to_array: + >-- turn a set into an array + >-- drops values + >function to_array(h) + > local result = {} + > for k, _ in pairs(h) do + > table.insert(result, k) + > end + > return result + >end +- __teliva_timestamp: original append: >-- concatenate list 'elems' into 'l', modifying 'l' in the process >function append(l, elems) @@ -257,6 +296,14 @@ > end >end - __teliva_timestamp: original + prepend: + >-- concatenate list 'elems' into the start of 'l', modifying 'l' in the process + >function prepend(l, elems) + > for i=1,#elems do + > table.insert(l, i, elems[i]) + > end + >end +- __teliva_timestamp: original all_but: >function all_but(x, idx) > if type(x) == 'table' then |