Libraryless. Click here for Pure Java version (219L/2K/6K).
!747 m { static S question = "Is port 80 open?"; p { if (args.length != 0) question = join(" ", args); L<S> tok = parse(question); //print(structure(tok)); print("Q: " + question); S[] match = match2(parse("is port * open"), tok); if (match != null) { int port = parseInt(match[0]); print("I'll check port " + port + "..."); boolean answer = isPortOpen(port); print("A: " + (answer ? "Yes, it is open!" : "No, it is not open.")); } else print("Unknown question: " + join(tok)); } static L<S> parse(S s) { return tokensToLowerCase(dropPunctuation(javaTokPlusPeriod(s))); } }
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: | 880 / 951 |
Referenced in: | [show references] |