/ http://blog.lab49.com/archives/906 / parse tree q:(+;(-:;19);(-;131;90)) / recursive, applicative order (ht attila for the simplification) e:{$[type x;x;get .z.s each x]} e q / reverse polish p:{$[type x;x;raze .z.s each reverse x]} p q / non-recursive e:{2 first/(0type n:first y;(x,n;1_y);(-1_x;n[last x],1_y)]}. x}/(();x)} e p q / factor into readable parts f:0type y;(x,y;z);(-1_x;y[last x],z)]} e:{2 first/f g[x]/(();y)}h e p q / we can use this technique to eliminate recursion converting to rpn h:{$[0=type y;(x;reverse[y],z);(x,y;z)]} p:{first f g[x]/(();enlist y)}h e p q / we can eliminate converting to rpn h:{$[0=t:type y;(x;reverse[y],z);100>t;(x,y;z);(-1_x;y[last x],z)]} e:{2 first/f g[x]/(();reverse y)}h e q / we can converge to empty queue g:{$[count y 1;{x[y;z 0;1_z]}[x]. y;y]} e:{2 first/g[x]over(();reverse y)}h e q / we can eliminate the internal lambda g:{$[count z;x[y;z 0]1_z;(y;z)]} e:{2 first/(g[x].)over(();reverse y)}h e q