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

16
LINES

< > BotCompany Repo | #1024501 // ai_parsePersonHeightStatement

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

Libraryless. Click here for Pure Java version (2613L/17K).

sS ai_parsePersonHeightStatement(S input) null on exception {
  Pair<Int> numbers = listToPair(map parseInt(regexpFirstGroupsIC("(\\d+)\\D+(\\d+)", input)));
  if (numbers != null) {
    int a, b = unpair numbers;
    if (a >= 5 && a <= 6 && b >= 0 && b <= 11)
      ret a + " foot " + b;
    else if (a >= 1 && a <= 2 && b >= 0 && b <= 99)
      ret a + "," + formatInt(b, 2) + " m";
  }
  
  int cm = parseFirstInt(input);
  if (cm >= 100 && cm <= 250)
    ret "Aha, you are " + cm + " cm";
    
  null;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024501
Snippet name: ai_parsePersonHeightStatement
Eternal ID of this version: #1024501/1
Text MD5: 052a6a4064fec451c9ad161a093b64c9
Transpilation MD5: b59b345a9d387333ad414dd1219f7bba
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-15 13:53:12
Source code size: 522 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 228 / 298
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)