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

40
LINES

< > BotCompany Repo | #1002431 // Is A Bot (developing)

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1311L/9K/29K).

1  
!752
2  
3  
!include #1002461 // Source
4  
5  
static Relationship<S, Source> isA;
6  
7  
p {
8  
  load("isA");
9  
}
10  
11  
answer {
12  
  L<S> tok = nlTok(s);
13  
  int i = findCodeTokens(tok, true, "is", "a");
14  
  if (i > 0) {
15  
    
16  
  }
17  
}
18  
19  
// This is about (directed) pair relationships: A * A -> V
20  
// For example, "A is a B" with V being a value type
21  
static class Relationship<A, V> {
22  
  Map<A, Map<A, V>> forward = new TreeMap;
23  
  Map<A, Map<A, V>> backward = new TreeMap;
24  
  
25  
  V get(A a, A b) {
26  
    Map<A, V> map = forward.get(a);
27  
    ret map == null ? null : map.get(b);
28  
  }
29  
  
30  
  void put(A a, A b, V v) {
31  
    put1(forward, a, b, v);
32  
    put1(backward, b, a, v);
33  
  }
34  
  
35  
  void put1(Map<A, Map<A, V>> x, A a, A b, V v) {
36  
    Map<A, V> map = x.get(a);
37  
    if (map == null) x.put(a, map = new TreeMap);
38  
    map.put(b, v);
39  
  }
40  
}

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: #1002431
Snippet name: Is A Bot (developing)
Eternal ID of this version: #1002431/1
Text MD5: b977dad73e594316fca35f59efa5f41b
Transpilation MD5: 73f625996a7a32513b1af54bb201075a
Author: stefan
Category: eleu
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-01-24 18:52:00
Source code size: 826 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 662 / 689
Referenced in: [show references]