Libraryless. Click here for Pure Java version (3876L/25K).
srecord MMOConsistencyError(int idx, S error) {} // items: pairs of example inputs (line-separated) + pattern static L<MMOConsistencyError> mmo_consistencyCheck(LPairS items) { new L<MMOConsistencyError> errors; for i over items: mmo_checkLocalConsistency(i, items.get(i), errors); ret errors; } svoid mmo_checkLocalConsistency(int idx, PairS qa, L<MMOConsistencyError> errors) { LS questions = tlft(qa.a); for (S q : questions) if (!mmo_match_parsedPattern(qa.b, q)) errors.add(MMOConsistencyError(idx, "Example " + quote(q) + " not matched by patterns " + quote(qa.b))); } svoid mmo_checkGlobalConsistency(int idx, PairS qa, LPairS items, L<MMOConsistencyError> errors) { LS questions = tlft(qa.a); for (S q : tlft(qa.a)) { int idxFound = mmo_indexOfFirstMatch(q, pairsB_lazy(items)); if (idxFound >= 0 && idxFound != idx) errors.add(new MMOConsistencyError(idx, "Example " + quote(q) + " (index " + (idx+1) + ") shadowed by patterns " + quote(items.get(idxFound).b) + " (item " + (idxFound+1) + ")"); } }
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1027551 |
| Snippet name: | mmo_consistencyCheck |
| Eternal ID of this version: | #1027551/5 |
| Text MD5: | 2289507d66bdf2d686ed2ac675b6e92e |
| Transpilation MD5: | f3d1125bf79b30839e51f95fff7cc388 |
| Author: | stefan |
| Category: | javax / linux |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-03-23 20:21:06 |
| Source code size: | 1078 bytes / 25 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 475 / 610 |
| Version history: | 4 change(s) |
| Referenced in: | [show references] |