Finding Clusters
This programs finds clusters as in percolation theory:
N:5
X:(1 0 1 0 1; 1 1 1 0 1; 0 1 0 1 0 ; 0 0 1 1 1; 1 0 0 0 1)
st:(N;N)#1+!N*N
u:{(1_ x),(1;N)#0}
l:{+(u(+x))}
d:{|(u(|x))}
r:{+(d(+x))}
s:{X*x|''(l x)|''(r x)|''(u x)|''d x}
s/(st*X)