/**  Combine and Isolate Terms **/
/*A: G Watson*/
/*S: University of Western Australia, Nedlands 6009, Australia*/
/*D: January, 1988 */
/*K: Isolate, Combine */
/*U: Feburary 1988 */
/*	Updated K McIsaac */

/*: Isot[$expr,($partspec:Null),{$terms}]
	Collects and isolates as a group  the terms specified by the partspec 
	$terms in the subexpression of $expr given by $partspec. */

<<XIso
Isot_: Tier
Isot[$x,$trm_=Listp[$trm]] :: (Lcl[%t,%tt,%term,%nterms]; \
			      %term : 0;%nterms : 1;\
	      		      Inc[%level];\
	      		      %t : 0; At[(%t:%t+$y),$x,Map[{$z},$trm]]; \
			      %tt : Nc[$x]($x/Nc[$x] - %t + Isolate[%t]); \
			      Dec[%level];\
			      %tt)
/* The numeric factor is pulled out the line 4 above to preserve the form
of the expression */

Isot[$x,$pos_=Listp[$pos],$trm_=Listp[$trm]] :: At[Isot[$y,$trm],$x,$pos]

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


#I[1]::  <XIsot

#I[2]::  a+b+c+d+x(e+f+g+h)

#O[2]:   a + b + c + d + x (e + f + g + h)

#I[3]::  Isot[%,{2,4}]

Entering level 1

%I[1]::  %

%O[1]:   b + d

%I[2]::  %^2

		2
%O[2]:   (b + d)

%I[3]::  Ret[]

Leaving level 1

					    2
#O[3]:   a + c + x (e + f + g + h) + (b + d)

#I[4]::  Isot[%,{{3,2}},{1,4}]

Entering level 1

%I[1]::  %

%O[1]:   e + h

%I[2]::  Sin[%]

%O[2]:   Sin[e + h]

%I[3]::  Ret[]

Leaving level 1

						 2
#O[4]:   a + c + x (f + g + Sin[e + h]) + (b + d)

#I[5]::  <end>
*/

