Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

26
LINES

< > BotCompany Repo | #1018773 // map_printProgress - map + print progress on console

JavaX fragment (include)

static L map_printProgress(Collection l, O f) {
  ret map_printProgress(f, l);
}

static L map_printProgress(O f, Collection l) {
  L x = emptyList(l);
  if (nempty(l)) {
    int i = 0, n = l(l);
    S desc = null;
    NotTooOften nto = onlyEverySecond();
    nto.yo(); // wait 1 second before printing
    bool printed = false;
    for (O o : l) {
      x.add(callF(f, o));
      ++i;
      if (nto.yo()) {
        printed = true;
        if (desc == null) desc = shorten(str(f), 20);
        print(desc + ": " + i + "/" + n);
      }
    }
    if (printed)
      print(desc + ": " + n + " done");
  }
  ret x;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1018773
Snippet name: map_printProgress - map + print progress on console
Eternal ID of this version: #1018773/5
Text MD5: 6614e1d705e5ee9afb753157b9ee7b24
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-13 16:07:59
Source code size: 638 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 357 / 383
Version history: 4 change(s)
Referenced in: [show references]