Percolation/Site percolation/J: Difference between revisions

m
no edit summary
m (flesh out examples a bit)
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 10:
<code>groups</code> uses a sum fold on successive prefixes to identify regions of contiguous bits.
 
<lang j> 12 10 12 0 1 0 1 10 0 1 01 1 1 0 1 10
12 10 12 0 1 0 1 10 0 1 01 1 1 0 1 10
* 2 </\0 2 0, 1 10 1 0 0 1 1 0 1 0 1 1 0 1 1
1 0 01 0 1 0 1 0 0 1 01 1 0 01 1 0
+/\(0, *) 2 </\0 2 0, 1 10 1 0 0 1 1 0 1 0 1 1 0 1 1
10 1 10 1 0 1 20 21 20 30 31 41 41 41 51 5</lang>0
(2 </\ 0, *) 2 0 2 0 1 0 1 0 0 1 1 1 1 1 0
1 0 1 0 1 0 1 0 0 1 0 0 0 0 0
([: +/\ 2 </\ 0, *) 2 0 2 0 1 0 1 0 0 1 1 1 1 1 0
1 1 2 2 3 3 4 4 4 5 5 5 5 5 5</lang>
 
<code>ooze</code> propagates 2s from its right argument to adjacent groups of non-zero locations in its left argument.
Line 197 ⟶ 201:
2 2 2 0 2 2 0 0 2 0 2 0 0 1 1</lang>
 
(^:_ repeats an operation until it reaches a [[wp:Fixed_point_(mathematics)|fixed point]]. In other words, it's basically a while loop.)
 
<code>trial</code> generates an arbitrary connection matrix and runs percolate on it. You'll typically get a different result from each trial.
6,951

edits