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

13
LINES

< > BotCompany Repo | #1027914 // allSubsetsOfSize_iterator [OK]

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

Libraryless. Click here for Pure Java version (2888L/18K).

1  
static <A> ItIt<L<A>> allSubsetsOfSize_iterator(int m, Cl<A> objects) {
2  
  L<A> list = asList(objects);
3  
  int n = l(list);
4  
  ret mapI(allSpreads(n-m, m+1), spread -> {
5  
    L<A> out = emptyList(m);
6  
    int i = -1;
7  
    for j to m: {
8  
      i += spread.get(j)+1;
9  
      out.add(list.get(i));
10  
    }
11  
    ret out;
12  
  });
13  
}

Author comment

Began life as a copy of #1010465

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027914
Snippet name: allSubsetsOfSize_iterator [OK]
Eternal ID of this version: #1027914/7
Text MD5: 1291c8a19c134f965bb4d0d9955290f7
Transpilation MD5: 522d2b04086787d4fd0c4909e928b45e
Author: stefan
Category: javax / maths
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-04-21 10:32:54
Source code size: 324 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 335 / 458
Version history: 6 change(s)
Referenced in: [show references]