Libraryless. Click here for Pure Java version (5018L/34K).
1 | scope queryUSZipCode {
|
2 | sS #dataSnippetID = #1400449; |
3 | |
4 | static SS queryUSZipCode(S zipCode) {
|
5 | if (l(zipCode) != 5 || !isInteger(zipCode)) null; |
6 | |
7 | File csvFile = loadLibrary(dataSnippetID); |
8 | S key = quote(zipCode); |
9 | S line = pairB(binarySearchForLineInTextFile(csvFile, |
10 | s -> cmp(key, dropAfterComma(s)))); |
11 | print(+line); |
12 | if (!startsWith(line, key)) null; |
13 | LS fields = unquoteAll(tok_splitAtComma(firstLineOfFile(csvFile))); |
14 | LS values = unquoteAll(tok_splitAtComma(line)); |
15 | ret zipTwoListsToMap(fields, values); |
16 | } |
17 | } |
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: | 501 / 635 |
| Version history: | 5 change(s) |
| Referenced in: | [show references] |