Libraryless. Click here for Pure Java version (2043L/14K/47K).
!752 static S inputText = [[ a point contains an "x coordinate" a point contains an "y coordinate" p is a point A is a B a B contains a C -> A contains a C ]]; static new L<S> statements; static new L<Rule> rules; p { inputText = anToA(inputText); L<S> log = toLinesTrim2(inputText); L<Int> emptyLines = concatLists(ll(-1), indexesOf(log, ""), ll(l(log))); for (int ii = 0; ii+1 < l(emptyLines); ii++) { int i = emptyLines.get(ii), j = emptyLines.get(ii+1); L<S> l = subList(log, i+1, j); continue if empty(l); L<Int> arrows = indexesOfLinesStartingWith(l, "->"); if (empty(arrows)) statements.addAll(l); } rules = parseRules(inputText); print("Rules:"); pslIndent(rules); print("Statements:"); printIndented(nlPrettyPrint(statements)); L<S> newStatements = inferStuff(); print("New statements:"); printIndented(nlPrettyPrint(newStatements)); } static L<S> inferStuff() { genLog_set(new L(statements)); for (Rule rule : rules) { L<SS> matches = asList(gSatAnd(rule.in)); for (S out : rule.out) for (SS match : matches) gAdd(replaceVars_autoQuote(out, match)); } ret new L(subList(gLog(), l(statements))); }
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004474 |
Snippet name: | A point contains... |
Eternal ID of this version: | #1004474/1 |
Text MD5: | 9d4c6c68eda47a714afb8d299782a10e |
Transpilation MD5: | ea35cfcbbeeb2ce4d6114014c133014b |
Author: | stefan |
Category: | javax / talking robots |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-08-18 20:41:59 |
Source code size: | 1268 bytes / 51 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 587 / 710 |
Referenced in: | [show references] |