// snlMatchX keeps existing matches static boolean snlMatchX(S pat, S snl, Map<S, Lisp> matches) { ret snlMatchX_sub(snlToTree_cached(pat), snlToTree(snl), matches); } static boolean snlMatchX(Lisp pat, S snl, Map<S, Lisp> matches) { ret snlMatchX_sub(pat, snlToTree(snl), matches); } static boolean snlMatchX(S pat, Lisp snl, Map<S, Lisp> matches) { ret snlMatchX_sub(snlToTree_cached(pat), snl, matches); } static boolean snlMatchX(Lisp pat, Lisp snl, Map<S, Lisp> matches) { ret snlMatchX_sub(pat, snl, matches); } static boolean snlMatchX_sub(Lisp pat, Lisp snl, Map<S, Lisp> m) { if (pat == null || snl == null) ret false; if (pat.isA("*")) ret true; if (startsWithUpperCase(pat.head)) ret snlMatchX_putMatch(m, pat.head, snl); if (neq(pat.head, snl.head)) ret false; // heads identical, proceed to children int n = pat.size(); if (n != snl.size()) ret false; for (int i = 0; i < n; i++) if (!snlMatchX_sub(pat.get(i), snl.get(i), m)) ret false; ret true; } static boolean snlMatchX_putMatch(Map<S, Lisp> matches, S key, Lisp val) { if (matches.containsKey(key) && neq(matches.get(key), val)) fail("multi-matching not implemented"); matches.put(key, val); ret true; }
Began life as a copy of #1002721
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: | #1002728 |
Snippet name: | snlMatchX |
Eternal ID of this version: | #1002728/1 |
Text MD5: | f0c213549bcdf5a64aa3214c9689b1bd |
Author: | stefan |
Category: | eleu / nl |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-02-19 21:43:36 |
Source code size: | 1293 bytes / 44 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 649 / 663 |
Referenced in: | #1002749 - snlMatch2 #1006654 - Standard functions list 2 (LIVE, continuation of #761) #3000382 - Answer for ferdie (>> t = 1, f = 0) |