sbool lispMatchIC_debug; static Map<S, Lisp> lispMatchIC(Lisp pat, Lisp nl, Collection<S> variables) { new Map<S, Lisp> matches; ret lispMatchIC_sub(pat, nl, variables, matches) ? matches : null; } static bool lispMatchIC_sub(Lisp pat, Lisp nl, Collection<S> variables, Map<S, Lisp> m) { if (pat == null || nl == null) ret false; if (pat.isLeaf() && variables.contains(pat.head)) { if (lispMatchIC_debug) print("Var: " + pat.head + " => " + nl); ret lispMatchIC_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_debug) print("Sub " + i + ": " + pat.get(i) + " => " + nl.get(i)); if (!lispMatchIC_sub(pat.get(i), nl.get(i), variables, m)) false; } true; } static bool lispMatchIC_putMatch(Map<S, Lisp> matches, S key, Lisp val) { if (matches.containsKey(key)) { if (!lispEqic(matches.get(key), val)) false; //fail("multi-matching not implemented"); } else matches.put(key, val); true; }
Began life as a copy of #1007704
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: | #1007821 |
Snippet name: | lispMatchIC - ignore case |
Eternal ID of this version: | #1007821/1 |
Text MD5: | 7f437fba8554b4b737bcc7cbfb2b9226 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-04-10 12:45:25 |
Source code size: | 1172 bytes / 38 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 530 / 557 |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1008096 - lispMatchIC_xyzVars - ignore case, assume X Y Z vars |