anchor.diff:  np.save( cls, clusters )
   }*
   
  -deftask evaluate( state1( File ) : cls( File ) ) in python *{
  +deftask reevaluate( state1( File ) : cls( File ) ) in python *{
   
   import numpy as np
   
  
positive.code: np.save( state1, newmu )
  }*
  
  deftask has_converged( <conv> : state0( File ) state( File ) ) in python *{
  
  import numpy as np
  
  oldmu = np.load( state0 )
  mu    = np.load( state )
  
  if set([tuple(a) for a in mu]) == set([tuple(a) for a in oldmu]):
    conv = ["true"]
  
negative.code:   conv = []
  }*
  
  deftask plot( png( File ) : cls( File ) k )in python *{
  
  import numpy as np
  import matplotlib.pyplot as plt
  
  clusters = np.load( cls ).item()
  k = int( k )
  col = ["r", "g", "b", "c"]
  
  for i in range( k ):
  
    N = np.array( clusters[ i ] )
    Nt = N.transpose()
    Nx = Nt[ 0 ]
    Ny = Nt[ 1 ]
  
    plt.plot( Nx, Ny, col[ i ]+"." )
  
  plt.axis( [-1.1, 1.1, -1.1, 1.1] )
  png = "fig.png"
  plt.savefig( png )
  }*
  
  deftask find_clusters( cls( File ) : data( File ) state( File ) ) {
  
    clusters = cluster( data: data, state: state );
    state1   = reevaluate( cls: clusters );
  
    cls = if has_converged( old: state, new: state1 )
          then
            clusters
          else
            find_clusters( data: data, state: state1 )
          end;
  }
  
  k = 4;
  N = 1600;
  
  X   = gen_data( N: N, k: k );
  mu0 = init_state( data: X, k: k );
  
  cls = find_clusters( data: X, state: mu0 );
  
  plt = plot( cls: cls, k: k );
  
  plt;