Hoopy frood
Joined: Nov 2003
Posts: 2,327 |
I remade it, but every so often it goes into an infinite loop and you have to ctrl+break it, but i'll post it anyway because someone else might know what's wrong with it. Here's some of the results for //echo -a $hnt(hello world!): he.lo world! h..lo.wo..d. h.llo world! h.l.o.w..l.! alias hnt {
var %i = 1, %l = $len($1), %r = $rand(0,6), %n, %ret
if (%r == 0) { return $1 }
while ($count(%ret,.) < $iif(%r > %l,%l,%r)) {
%i = 1
while (%i < %l) {
if ($rand(1,2) == 1) && (%n != %r) && ($mid($iif(%ret,$v1,$1),%i,1) != .) {
%ret = $+($mid($iif(%ret,$v1,$1),1,%i),.,$mid($iif(%ret,$v1,$1),$calc(%i + 2)))
inc %n
}
inc %i
}
}
return %ret
} Edit: Heh, my bad, I did the opposite of what you wanted ($rand(0,6) were .s, not letters), here's the one you want (and it doesn't seem to go into an infinite loop ): alias hnt {
var %i = 1, %l = $len($1), %r = $rand(0,6), %n, %ret
.echo -q $regsub($1,/./g,\.,%ret)
while ($regex(%ret,/[^\.]/g) < $iif(%r > %l,%l,%r)) {
%i = 1
while (%i < %l) {
if ($rand(1,2) == 1) && (%n != %r) {
%ret = $+($iif(%i > 1,$mid(%ret,1,$calc(%i - 1))),$mid($1,%i,1),$mid(%ret,$calc(%i + 1))))
inc %n
}
inc %i
}
}
return %ret
}
Last edited by tidy_trax; 11/10/04 06:21 PM.
New username: hixxy
|