Search code examples
kdb

Uniform list pretty-printer


It is known that default printer can be confusing wrt lists because of no output for empty lists and 3 different notations being mixed (, vs (x;y;z) vs 1 2 3) and not obvious indentation/columnization (which is apparently optimized for table data). I am currently using -3! but it is still not ideal.

Is there a ready-made pretty-printer that has consistent uniform output format (basically what I am used to in any other language where list is not special)?


Solution

  • I've started using .j.j for string outputs in error messages more recently in preference to -3!. Mainly I think it is easier to parse in a text log, but also doesn't truncate in the same way.

    It still transforms atoms and lists differently so it might not exactly meet your needs, if you really want that you could compose it with the old "ensure this is a list" trick:

    myPrinter:('[.j.j;(),])