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).

1  
static <A> A[] repF_array(int n, IF0<A> f) {
2  
  A[] a = cast new O[n];
3  
  for i to n:
4  
    a[i] = f.get();
5  
  ret a;
6  
}
7  
8  
static <A> A[] nuLike repF_array(Class<A> type, int n, IF0<A> f) {
9  
  A[] a = newArrayOfType(type, n);
10  
  for i to n:
11  
    a[i] = f.get();
12  
  ret a;
13  
}

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: 206 / 302
Version history: 4 change(s)
Referenced in: [show references]