Posted to tcl by kostix at Mon Aug 25 22:44:18 GMT 2008view pretty
proc foo text { set words [regexp -all -indices -inline {[^[:punct:]\s]+} $text] set nwords [llength $words] array set seen {} set out $text for {set i 0} {$i <= int(rand() * $nwords)} {incr i} { while 1 { set ix [expr {int(rand() * $nwords)}] if {![info exists seen($ix)]} break } set seen($ix) yo! lassign [lindex $words $ix] a b set out [string replace $out $a $b [string repeat * [expr {$b - $a + 1}]]] } set out }
Comments
Posted by patthoyts at Mon Aug 25 23:15:11 GMT 2008 [text] [code]
testing
Posted by patthoyts at Wed Aug 27 13:40:45 GMT 2008 [text] [code]
another test