Comment by g9550684
9 hours ago
> convert tables to lists
array languages give you concepts for thinking about these problems where you can succinctly express that entire talk in a single sentence, something like "inverted tables improve cache locality and optimize for time and space, prefer them where it matters". yes, got it, also a well known conclusion in array world.
a table is a 2 dimensional data that stores your records row by row and the items of a column all have the same data type. the way an array of structs would. an inverted table is a list of original table's columns. like a struct of arrays.
so if you have a table,
x
┌────┬──────┬─┬─────────┐
│mob1│level1│0│0.0243902│
├────┼──────┼─┼─────────┤
│mob2│level2│1│0.0147059│
├────┼──────┼─┼─────────┤
│mob3│level2│0│0.0120482│
└────┴──────┴─┴─────────┘
there's an idiom for converting it to an inverted table
]y=:(<@(>"1)@|:)x
┌────┬──────┬─────┬─────────────────────────────┐
│mob1│level1│0 1 0│0.0243902 0.0147059 0.0120482│
│mob2│level2│ │ │
│mob3│level2│ │ │
└────┴──────┴─────┴─────────────────────────────┘
you can then splice it across variables,
'name level isactive v'=:y
isactive
0 1 0
so you have converted a table to lists.
No comments yet
Contribute on Hacker News ↗