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

31
LINES

< > BotCompany Repo | #1001299 // standardQuery, additionalQuery

JavaX fragment (include)

1  
  // TODO: maps (e.g. #1001307)
2  
3  
  static S additionalQuery(S s, S varName, S thing) {
4  
    O value = get(main.class, varName);
5  
    if (!(value instanceof List)) return null;
6  
    L<S> list = (L<S>) value;
7  
    
8  
    if (match3("how many " + thing + "s", s))
9  
      return "" + list.size();
10  
      
11  
    if (match3("structure " + thing + "s", s))
12  
      return structure(list);
13  
      
14  
    return null;
15  
  }
16  
  
17  
  static S standardQuery(S s, S varName) {
18  
    O value = get(main.class, varName);
19  
    if (isType(value, "main$AList"))
20  
      value = call(value, "shoot");
21  
    if (!(value instanceof List)) return null;
22  
    L list = (L) value;
23  
    
24  
    if (match3("how many entries", s) || match3("n", s))
25  
      return "" + list.size();
26  
    
27  
    if (match3("structure", s))
28  
      return structure(list);
29  
      
30  
    return null;
31  
  }

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: #1001299
Snippet name: standardQuery, additionalQuery
Eternal ID of this version: #1001299/1
Text MD5: 0927d61b388a32c2c21e13faa9398b7c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-10-20 23:52:43
Source code size: 845 bytes / 31 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 646 / 962
Referenced in: [show references]