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

7
LINES

< > BotCompany Repo | #1006857 // applyUntilStable - repeatedly apply a function to an object until the object doesn't change anymore (checking using eq)

JavaX fragment (include)

1  
static <A> A applyUntilStable(O f, A a) {
2  
  while true {
3  
    A b = cast callF(f, a);
4  
    if (eq(a, b)) ret b;
5  
    a = b;
6  
  }
7  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1006857
Snippet name: applyUntilStable - repeatedly apply a function to an object until the object doesn't change anymore (checking using eq)
Eternal ID of this version: #1006857/4
Text MD5: c9a0ec3caadb129cb4261ede928a5af1
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-02-10 19:49:27
Source code size: 132 bytes / 7 lines
Pitched / IR pitched: No / No
Views / Downloads: 523 / 529
Version history: 3 change(s)
Referenced in: [show references]