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

13
LINES

< > BotCompany Repo | #1030532 // repF_array - call a function repeatedly, collect as object array

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (54L/1K).

static <A> A[] repF_array(int n, IF0<A> f) {
  A[] a = cast new O[n];
  for i to n:
    a[i] = f.get();
  ret a;
}

static <A> A[] nuLike repF_array(Class<A> type, int n, IF0<A> f) {
  A[] a = newArrayOfType(type, n);
  for i to n:
    a[i] = f.get();
  ret a;
}

Author comment

Began life as a copy of #1025074

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030532
Snippet name: repF_array - call a function repeatedly, collect as object array
Eternal ID of this version: #1030532/5
Text MD5: b36159bb670e91588ebb3d97b53935da
Transpilation MD5: 6ec12a406a6ada6f53007f40ac65ac60
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-01-06 17:10:02
Source code size: 274 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 123 / 195
Version history: 4 change(s)
Referenced in: [show references]