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

17
LINES

< > BotCompany Repo | #1030439 // queryUSZipCode

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

Libraryless. Click here for Pure Java version (5018L/34K).

scope queryUSZipCode {
  sS #dataSnippetID = #1400449;

  static SS queryUSZipCode(S zipCode) {
    if (l(zipCode) != 5 || !isInteger(zipCode)) null;
    
    File csvFile = loadLibrary(dataSnippetID);
    S key = quote(zipCode);
    S line = pairB(binarySearchForLineInTextFile(csvFile,
      s -> cmp(key, dropAfterComma(s))));
    print(+line);
    if (!startsWith(line, key)) null;
    LS fields = unquoteAll(tok_splitAtComma(firstLineOfFile(csvFile)));
    LS values = unquoteAll(tok_splitAtComma(line));
    ret zipTwoListsToMap(fields, values);
  }
}

Author comment

Began life as a copy of #1028338

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030439
Snippet name: queryUSZipCode
Eternal ID of this version: #1030439/6
Text MD5: 389eed58f4548a08b9a60009cafe9c17
Transpilation MD5: e2e30cc75fd1478afa75ee8915e948e4
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-12-17 18:24:33
Source code size: 573 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 141 / 210
Version history: 5 change(s)
Referenced in: [show references]