sbool lispMatchIC_xyzVars_debug; static Map<S, Lisp> lispMatchIC_xyzVars(Lisp pat, Lisp nl) { new Map<S, Lisp> matches; ret lispMatchIC_xyzVars_sub(pat, nl, matches) ? matches : null; } // put additional vars in m with value = null static bool lispMatchIC_xyzVars_sub(Lisp pat, Lisp nl, Map<S, Lisp> m) { if (pat == null || nl == null) ret false; if (pat.isLeaf() && (isXYZVar(pat.head) || m.containsKey(pat.head))) { if (lispMatchIC_xyzVars_debug) print("Var: " + pat.head + " => " + nl); ret lispMatchIC_xyzVars_putMatch(m, pat.head, nl); } if (neqic(pat.head, nl.head)) ret false; // heads identical, proceed to children int n = pat.size(); if (n != nl.size()) ret false; for (int i = 0; i < n; i++) { if (lispMatchIC_xyzVars_debug) print("Sub " + i + ": " + pat.get(i) + " => " + nl.get(i)); if (!lispMatchIC_xyzVars_sub(pat.get(i), nl.get(i), m)) false; } true; } static bool lispMatchIC_xyzVars_putMatch(Map<S, Lisp> matches, S key, Lisp val) { Lisp oldValue = matches.get(key); if (oldValue != null) { if (!lispEqic(oldValue, val)) false; //fail("multi-matching not implemented"); } else matches.put(key, val); true; }
Began life as a copy of #1007821
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1008096 |
Snippet name: | lispMatchIC_xyzVars - ignore case, assume X Y Z vars |
Eternal ID of this version: | #1008096/3 |
Text MD5: | b709781c7adcba8561588096c05d062e |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-05-07 00:22:11 |
Source code size: | 1259 bytes / 40 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 463 / 480 |
Version history: | 2 change(s) |
Referenced in: | [show references] |