12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- / :`i$"A"; // 65
- / :`i$"Z"; // 90
- / :`i$"0"; // 48
- / :`i$"9"; // 57
- / :`i$":"; // 58
- / :`i$"$"; // 36
- testAtZ: { i:`i$x; $[(i>64) & (i<91);1;0] };
- test0t9: { i:`i$x; $[(i>47) & (i<58);1;0] };
- testcol: { i:`i$x; $[i=58;1;0] };
- testend: { i:`i$x; $[i=36;1;0] };
- s0: ((testAtZ; 1);(test0t9; 2));
- s1: ((test0t9; 2);(testcol; 3));
- s2: ((testend; 7); (testcol;5));
- s3: (,(testAtZ; 5));
- s4: ((testAtZ; 5); (test0t9; 5));
- s5: (,(testend; 6));
- s7: (({`0:"SUCCESS"};6));
- // 7 is done
- states:: (s0;s1;s2;s3;s4;s5;s7);
- i: 1;
- run: {[str]
- // go over each char and run cur statoe
- // cur state; start of pattern; length of pattern <- args
- idx::0;
- o:(0;(0;0);1) {[a;c]
- activeidx: (*|a);
- indices: a[activeidx];
- s: a[0];
- r:{
- :$[x[0][y];x[1];0]
- }[;c]'states[s];
- r: *($[(+/r)>0;r^0;0]);
- idx +: 1;
- a0: $[s>4;s;r];
- :(a0;($[(s=0)&(r>0);idx-1;indices[0]];$[r=5;idx;indices[1]]);activeidx)
- }\str;
- :o
- };
|