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

22
LINES

< > BotCompany Repo | #1035566 // stupidFib_collab - Stupid-Fib in parallel (old)

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

Transpiled version (9165L) is out of date.

static long stupidFib_collab(ICollab collab, int n) {
  new Var<Long> var;
  stupidFib_collab(collab, n, result -> {
    var.set(result);
    collab.done();
  });
  collab.run();
  ret var!;
}

svoid stupidFib_collab(ICollab collab, int n, LongConsumer continuation) {
  if (n < 3) ret with continuation.accept(1L);
  
  LongPairCollector collector = new {
    void complete(long a, long b) {
      continuation.accept(a+b);
    }
  };
  
  collab.addWork(-> stupidFib_collab(collab, n-1, collector.setterForA()));
  collab.addWork(-> stupidFib_collab(collab, n-2, collector.setterForB()));
}

Author comment

Began life as a copy of #1035559

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): elmgxqgtpvxh, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035566
Snippet name: stupidFib_collab - Stupid-Fib in parallel (old)
Eternal ID of this version: #1035566/12
Text MD5: 48cc5845d2b7cf3082fb12082ec1a29f
Author: stefan
Category: javax / maths
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-06-19 02:14:22
Source code size: 613 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 85 / 195
Version history: 11 change(s)
Referenced in: [show references]