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

40
LINES

< > BotCompany Repo | #1026485 // Suffixes/Prefixes Continuation Framework Spike [dev.]

JavaX source code (Dynamic Module) - run with: Stefan's OS

1  
!7
2  
3  
abstract sclass Continuation {
4  
}
5  
6  
srecord Parallel(Continuation *options) > Continuation {
7  
}
8  
9  
cmodule ContinuationTest > DynPrintLog {
10  
  transient LS
11  
    prefixes = ll("un", "pre"),
12  
    suffixes = ll("able", "like");
13  
14  
  start-thread {
15  
    processInput("unrepairable");
16  
  }
17  
  
18  
  // original version without continuations
19  
  void processInput(S input) {
20  
    for (S s : prefixes)
21  
      if (swic(input, s))
22  
        emit(joinPairWithSpace(pairOfNFirstAndRest(input, l(s))));
23  
    for (S s : suffixes)
24  
      if (ewic(input, s))
25  
        emit(joinPairWithSpace(pairOfRestAndNLast(input, l(s))));
26  
  }
27  
  
28  
  Continuation processInput2(S input) {
29  
    ret Parallel(
30  
      ParallelFor(prefixes, s -> {
31  
        if (swic(input, s))
32  
          emit(joinPairWithSpace(pairOfNFirstAndRest(input, l(s))))
33  
      }),
34  
      ParallelFor(suffixes, s -> {
35  
        if (ewic(input, s))
36  
          emit(joinPairWithSpace(pairOfRestAndNLast(input, l(s))));
37  
      })
38  
    );
39  
  }
40  
}

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: #1026485
Snippet name: Suffixes/Prefixes Continuation Framework Spike [dev.]
Eternal ID of this version: #1026485/1
Text MD5: 8ecb616a51e10c71b591a9d2a1067e2e
Author: stefan
Category: javax / a.i.
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-01-06 16:26:56
Source code size: 987 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 143 / 178
Referenced in: [show references]