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

31
LINES

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

JavaX fragment (include)

  // TODO: maps (e.g. #1001307)

  static S additionalQuery(S s, S varName, S thing) {
    O value = get(main.class, varName);
    if (!(value instanceof List)) return null;
    L<S> list = (L<S>) value;
    
    if (match3("how many " + thing + "s", s))
      return "" + list.size();
      
    if (match3("structure " + thing + "s", s))
      return structure(list);
      
    return null;
  }
  
  static S standardQuery(S s, S varName) {
    O value = get(main.class, varName);
    if (isType(value, "main$AList"))
      value = call(value, "shoot");
    if (!(value instanceof List)) return null;
    L list = (L) value;
    
    if (match3("how many entries", s) || match3("n", s))
      return "" + list.size();
    
    if (match3("structure", s))
      return structure(list);
      
    return null;
  }

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: 647 / 962
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)