Method code for $data_lib.unparse_indent()

[Turn off line numbering]
  1: arg value;
  2: var s, i, len;
  3: 
  4: refresh();
  5: switch (type(value)) {
  6:     case 'list:
  7:         if (!value)
  8:             return ["[]"];
  9:         s = map i in [1 .. (len = value.length())] to (.unparse_indent(value[i]).affix(i < len ? "," : "")).sum();
 10:         s ?= [];
 11:         if (s.mmap('length).sum() < 60) {
 12:             return ["[" + s.join() + "]"];
 13:         } else {
 14:             s = s.prefix("  ");
 15:             s = s.replace(1, s[1].subrange(3));
 16:             return ["[ "].affix(s).affix("]");
 17:         }
 18:     case 'dictionary:
 19:         s = map i in [1 .. (len = value.keys().length())] to (.unparse_indent([(value.keys())[i], value[(value.keys())[i]]]).affix(i < len ? "," : "")).sum();
 20:         s ?= [];
 21:         if (s.mmap('length).sum() < 60) {
 22:             return ["#[" + s.join() + "]"];
 23:         } else {
 24:             s = s.prefix("  ");
 25:             s = s.replace(1, s[1].subrange(3));
 26:             return ["#["].affix(s).affix("]");
 27:         }
 28:     case 'frob:
 29:         return ["<"].affix(class(value)).affix(",").affix(.unparse_indent(value.value())).affix(">");
 30:     default:
 31:         return [toliteral(value)];
 32: }

// Created 07-Dec-1996 as a part of ColdCore, see: @help Credit

Tlon