/ atw, sa - parse categories / categories N:"abcdefghijklmnopqrstuvwxyz0123456789" / nouns V:":+-*%&|<>=~.!@?#_^,$ABCDEFGHIJKLMNOPQRSTUVWXYZ" / verbs A:"'/\\" / adverbs / type T:{" ()nva"@sum(til 6)*(first each x)in/:(flip enlist" ()"),(N;V;A)} / x -> " ()nva" / universe M:floor .2*count U:raze("()a";" va";" va";" n ";" n ") / universe of types / reduce R:{$[any z@:C[x]0;@[x;first i;:;y each(flip i:-1 0+flip 0N 2#1_where not 1=(=)prior not z,0)(first@_)\:x]where not z;x]} r:{mod[floor x%M]3} / rank i:{x-M*a[1 rotate x]&v x} / preprocess v a j:{x@\:where not 3=first x} / no blanks p:{-1 rotate 0)prior v@ / first verbs Y:{c[3 0],k -1_1_raze x} / (x)-> k x X:{c C[i]+(M*not til count i:raze reverse x;0)} / xy->yx k:{raze R/[flip enlist x;(Y;X;X);(p;a;b)]} / raze reduce over c:0 1000/: / encode value + position C:1000\: / decode value + position / parse P:{(x;(enlist[""],w)p;(til 4)a[d]+r d:first e;-1+p:last e:j C k c(i U?/:t;1+til count t:T w:-4!x))} / evaluate from (reverse) polish E:{2 first/{f[first x;first x 1]. 1_x 1}over(();@[x;1+til 3;reverse])} e:{`$z," error\n",x,"\n",(neg y+1)$enlist"^"} f:{[z;x;p;v;i]$[not count p;(z;(x;p;v;i));not first v;(z,enlist g first p;(enlist x),1_'(p;v;i));((w _z),enlist .[g first p;reverse(w:neg first v)#z;e[x]first i];(enlist x),1_'(p;v;i))]} g:{(each;over;scan;prior;{y x/:z};{y x\:z};value x)("",/:("'";"/";"\\";"':";"/:";"\\:"))?x} P"a+/:\\::b" P"a+0" P"abc" P"(a+b)" P"+a" P"x*:/y" P"+((x+y)*z)" P"y@x+*:/'-x*/y" P"(a+b)*-c%d" P"v-(x+y)-((z-k)+w)*a" x:til 10;E P"+/x" \ / reduce R:{$[not any z@:C[x]0;x; [a:1_where not 1=(=)prior not z,0; i:-1 0+flip 0N 2#a; b:(flip i)(first@_)\:x; c:y each b; d:@[x;first i;:;c]; r:d where not z; r]]}