aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc
diff options
context:
space:
mode:
authorCalvin Rose <calsrose@gmail.com>2021-11-11 21:54:53 -0600
committerGitHub <noreply@github.com>2021-11-11 21:54:53 -0600
commit0bfde759576ad40dc735059cb36662193fb706ee (patch)
tree3f1fe7d5e72fa09d73f3965d99aae66df6529e2b /doc
parentMerge branch 'master' of github.com:janet-lang/spork (diff)
parentUpdate misc.mdz (diff)
Merge pull request #56 from uvtc/patch-1
doc example for misc/print-table
Diffstat (limited to 'doc')
-rw-r--r--doc/misc.mdz26
1 files changed, 26 insertions, 0 deletions
diff --git a/doc/misc.mdz b/doc/misc.mdz
index 21a1559..f4020e0 100644
--- a/doc/misc.mdz
+++ b/doc/misc.mdz
@@ -34,3 +34,29 @@ hand sides are computed before setting the left hand sides.)
(misc/set* [[x 0] [x 1]] [(in x 1) (+ (in x 0) (in x 1))])
x => @[3 5]
```
+
+## `print-table`
+
+Given a list of tables containing column keys with corresponding row
+values, print its content to stdout in a human-readable tabular
+layout. For example:
+
+@codeblock[janet]```
+(misc/print-table [
+ {:x "abc" :y "123"}
+ {:x "hello" :y "world"}
+ {:x "banana" :y "orange"}
+ {:x "cat" :y "dog"}])
+
+```
+
+produces:
+
+@codeblock```
+x y
+════════════════
+ abc 123
+ hello world
+ banana orange
+ cat dog
+```