
macro=;
/*
    This is the script used in Goloboff et al's paper,
    (Phylogenetic of 73,060 taxa corroborates...).
    See paper for details of usage.
*/

xr=!0 [.] B ;

var : curstat namstats[300] prev[300] now[30] curarg i j ;

set curstat 0 ;
set curarg 1 ; 
set namstats $Groups ;
set j root ; 

report- ; 
loop 1 argnumber

   if ( 'curstat' > 9 ) errmsg Cannot define more than 10 distinct states! ; end 
   xread =! 0 [ :%('curarg') ] 'curstat' ;
   keep 1 ; 

agroup =0 :%('curarg') ;
tr ( ( { 0 } ) ... ) ;

/*
   tr ( ( :%('curarg') ) ... ) ;
*/

   pruntax 1 / .-@0 'j' ;
   set i numdes[1 (root+1)] ;
   keep 1 ; 
   set now $ %('curarg')('i') ;
   set prev $ $namstats; 
   set namstats $ $prev $now;
   set curstat ++ ;
   set curarg ++ ; 

stop

report=;

xr == ; 

loop 0 10 
   if ( 'curstat' >= 10 ) endloop ; end 
   set prev $ $namstats; 
   set namstats $ $prev (nothing) ;
   set curstat ++ ;
stop 
   
quote $namstats ;
cn {0 $namstats ;

ttag - ;
ttag = ; 
map 0 / 0 ;

if ( windows )
    ttag : ;
else
    ttag ;
    end 

proc/;

