Libraryless. Click here for Pure Java version (219L/2K/6K).
1 | !747 |
2 | |
3 | m {
|
4 | static S question = "Is port 80 open?"; |
5 | |
6 | p {
|
7 | if (args.length != 0) |
8 | question = join(" ", args);
|
9 | L<S> tok = parse(question); |
10 | //print(structure(tok)); |
11 | print("Q: " + question);
|
12 | S[] match = match2(parse("is port * open"), tok);
|
13 | if (match != null) {
|
14 | int port = parseInt(match[0]); |
15 | print("I'll check port " + port + "...");
|
16 | boolean answer = isPortOpen(port); |
17 | print("A: " + (answer ? "Yes, it is open!" : "No, it is not open."));
|
18 | } else |
19 | print("Unknown question: " + join(tok));
|
20 | } |
21 | |
22 | static L<S> parse(S s) {
|
23 | return tokensToLowerCase(dropPunctuation(javaTokPlusPeriod(s))); |
24 | } |
25 | } |
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1000809 |
| Snippet name: | Answer questions |
| Eternal ID of this version: | #1000809/1 |
| Text MD5: | c71fb076ddb51fa6b0050e80bf31ff1e |
| Transpilation MD5: | 3b7ee11f520711e505bf559e1292c860 |
| Author: | stefan |
| Category: | |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-08-28 19:35:56 |
| Source code size: | 681 bytes / 25 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 1370 / 1564 |
| Referenced in: | [show references] |