table function

void table(
  1. List<String> input
)

Implementation

void table(List<String> input) {
  const int columnCount = 5;
  int remaining = columnCount - (input.length % columnCount), i;
  if (remaining < columnCount) {
    for (i = 0; i < remaining; i++) {
      input.add('');
    }
  }
  for (i = 0; i < input.length; i += columnCount) {
    String row = '';
    for (int j = 0; j < columnCount; j++) {
      if (input[i + j] == '') continue;
      row += '${input[i + j]}\t';
    }
    stdout.writeln(row);
  }
}