Libraryless. Click here for Pure Java version (2275L/14K).
1 | sclass MatchableRecords<A extends IFieldsToList> { |
2 | new L<A> records; |
3 | |
4 | *() {} |
5 | *(A... records) { addAll(this.records, records); } |
6 | |
7 | O fulfillVariable(IF1<Var, A> makeRecord) { |
8 | new Var var; |
9 | O result = null; |
10 | A record = makeRecord.get(var); |
11 | O[] a = record._fieldsToList(); |
12 | bigLoop: for (A r : records) { |
13 | if (r.getClass() != record.getClass()) continue; |
14 | O[] b = r._fieldsToList(); |
15 | if (b.length != a.length) fail("Bad argument length: " + record); |
16 | for i over a: |
17 | if (a[i] == var) { |
18 | if (result != null && !eq(result, b[i])) |
19 | continue bigLoop; |
20 | result = b[i]; |
21 | } else |
22 | if (!eq(a[i], b[i])) |
23 | continue bigLoop; |
24 | |
25 | ret result; |
26 | } |
27 | null; |
28 | } |
29 | } |
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025430 |
Snippet name: | MatchableRecords |
Eternal ID of this version: | #1025430/3 |
Text MD5: | b56a2f2c222f7655c00eaf6f8ac36f65 |
Transpilation MD5: | 90282f56d9ee1531a2fce0628fe24ca7 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-09-28 23:49:20 |
Source code size: | 799 bytes / 29 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 219 / 603 |
Version history: | 2 change(s) |
Referenced in: | [show references] |