From fddbe08fc896e09d0fec2773977341d72103ff90 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 19 Mar 2022 16:59:30 -0700 Subject: 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. --- template.tlv | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'template.tlv') diff --git a/template.tlv b/template.tlv index 49d35ed..c82d274 100644 --- a/template.tlv +++ b/template.tlv @@ -248,6 +248,45 @@ > end > 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 @@ -256,6 +295,14 @@ > table.insert(l, elems[i]) > 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) -- cgit 1.4.1-2-gfad0