1 | abstract sclass Op extends F1 {} |
2 | |
3 | sclass ApplySF extends Op { |
4 | S name; |
5 | int pos; |
6 | L args; |
7 | |
8 | *() {} |
9 | *(S *name) { args = ll(); } |
10 | *(S *name, int *pos, O... args) { this.args = asList(args); } |
11 | |
12 | O get(O o) { |
13 | L args = cloneList(this.args); |
14 | args.add(pos, o); |
15 | ret makeAndCall(name, toObjectArray(args)); |
16 | } |
17 | } |
18 | |
19 | sclass ApplyFunc extends Op { |
20 | S code; |
21 | |
22 | *() {} |
23 | *(S code) { this.code = trim(code); } |
24 | |
25 | O get(O o) { |
26 | ret evalFuncWithImportExport(code, o); |
27 | } |
28 | } |
29 | |
30 | sclass MapSF extends Op { |
31 | Op op; |
32 | |
33 | *() {} |
34 | *(Op *op) {} |
35 | |
36 | O get(O o) { |
37 | ret map(op, (Collection) o); |
38 | } |
39 | } |
40 | |
41 | sclass Operation { |
42 | Op op; |
43 | Data result; |
44 | |
45 | *() {} |
46 | *(Op *op) {} |
47 | } |
48 | |
49 | sclass Data { |
50 | O data; |
51 | PersistableThrowable error; |
52 | new L<Operation> operations; |
53 | |
54 | *() {} |
55 | *(O *data) {} |
56 | } |
57 | |
58 | static Data initial; |
59 | |
60 | svoid printTree(Data data) { |
61 | if (data == null) { print("-"); ret; } |
62 | if (data.error != null) print("Error: " + data.error); |
63 | else { |
64 | print_noNL("Data: "); |
65 | if (data.data instanceof Collection) |
66 | print_noNL("[" + l(data.data) + "] "); |
67 | else if (data.data instanceof S) { |
68 | int n = numLines((S) data.data); |
69 | if (n > 1) print_noNL("[" + n + " lines] "); |
70 | } |
71 | print(shorten(struct(data.data))); |
72 | } |
73 | print_threadIndentPlus(); |
74 | try { |
75 | int i = 0; |
76 | for (Operation op : data.operations) { |
77 | print("Op " + (++i) + ": " + struct(op.op)); |
78 | printTree(op.result); |
79 | } |
80 | } finally { |
81 | print_threadIndentMinus(); |
82 | } |
83 | } |
84 | |
85 | static Data doOp(Data data, Op theOp) { |
86 | Operation op = new Operation(theOp); |
87 | data.operations.add(op); |
88 | try { |
89 | op.result = new Data(op.op.get(data.data)); |
90 | } catch e { |
91 | op.result = nu(Data, error := persistableThrowable(e)); |
92 | } |
93 | ret op.result; |
94 | } |
Began life as a copy of #1008513
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: | #1008522 |
Snippet name: | Analysis Tree [Include] |
Eternal ID of this version: | #1008522/9 |
Text MD5: | 90de1a0c244b3a29493a1d28ab5207c8 |
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-21 15:26:00 |
Source code size: | 1826 bytes / 94 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 440 / 880 |
Version history: | 8 change(s) |
Referenced in: | [show references] |