Percolation/Mean run density: Difference between revisions

m
→‎{{header|Tcl}}: Add some explanatory comments
(→‎Tcl: Added implementation)
m (→‎{{header|Tcl}}: Add some explanatory comments)
Line 136:
return $s
}
 
# By default, [regexp -all] gives the number of times that the RE matches
proc runs {str} {
regexp -all {1+} $str
}
 
# Compute the mean run density
proc mrd {t p n} {
for {set i 0;set total 0.0} {$i < $t} {incr i} {
Line 148 ⟶ 151:
}
 
# Parameter sweep with nested [foreach]
set runs 500
foreach p {0.10 0.30 0.50 0.70 0.90} {
Anonymous user