/**  Structure Determination  **/
/*A: G I Watson */
/*S: University of Western Australia */
/*D: April 1987 */
/*K: Structure, Tree */

/*: Struc[$expr,($lev:1)]
	returns the given expression $expr with all complicated (depth>3)
	parts (at level $lev) replaced by the special output form <depth>.
	This makes it easier to see the overall structure of a large
	expression. Further operations may be carried out on the expression
	while in special output form, and Unstruc applied later to return 
	to normal. */
/*: Unstruc[$expr]
	reverses the effect of Struc. */

Struc_: Tier
Struc[$expr] :: Struc[$expr,1]
Struc[$expr,$lev] :: Map[StrucPr,$expr,{$lev}]

StrucPr[$x_=Dep[$x]<4] :: $x
_StrucPr[Pr][$x] :: Fmt[,"<",Dep[$x],">"]

Unstruc[$expr] :: S[$expr,StrucPr[$x_=Dep[$x]>3]->$x]

/*E:
SMP 1.5.0   (May 14 1986)
Tue Apr 21 17:34:43 1987


#I[1]::  <XStruc

#I[2]::  f:Pf[x/((a x^2+2b x-c)(2a x^2-c)(2b x-c)),x];

#I[3]::  Struc[f,3]

	     1  		c             <15> + <14>     <12> + <14>
#O[3]:*  ---------- - --------------------- + ----------- + ---------------
	 2b <5> <7>   2b (c - 2b x) <5> <7>            2	   2
					       c - 2a x     c - a x  - 2b x

		   <9> + <9> + <12>   <9> + <9> + <9>
		 - ---------------- - ---------------
			  2a    	     a

#I[4]::  Rat[%[1]+%[2]]

		 -x
#O[4]:*  ------------------
	 (c - 2b x) <5> <6>

#I[5]::  Unstruc[%]

				   4
			       -8 b  x
#O[5]:   ----------------------------------------------------
			2      2		 2       2
	 (c - 2b x) (a c  - 2 b  c) (c (a c + 4 b ) - 4 b  c)
*/

