Perl: the Markov chain saw PerlMonks

### Tristable oscillator

by Prof Vince (Friar)
 on Jul 08, 2008 at 21:08 UTC Need Help??

use strict; use warnings; local \$\ = "\n"; local \$_ = 'y,ys,sy,,s,ys,sy,'; for my \$n (1 .. \$ARGV[0] || 10) { print; eval; } print;
It's not really that hard to understand. Do you have longer ones of this kind ?

Replies are listed 'Best First'.
Re: Tristable oscillator
by ikegami (Pope) on Jul 08, 2008 at 21:47 UTC
Very neat! But it has four states.
State 1: y,ys,sy,,s,ys,sy, State 2: s,sy,sy,,y,sy,ys, State 3: y,ys,ys,,s,ys,sy, State 4: y,sy,ys,,s,ys,sy, State 2: s,sy,sy,,y,sy,ys, ...

That it has a distinct "initializing" state could seen as an advantage. If not, change the initial string to one of states 2, 3 or 4 to get a purely three state engine.

State 1: y,sy,ys,,s,ys,sy, State 2: s,sy,sy,,y,sy,ys, State 3: y,ys,ys,,s,ys,sy, State 1: y,sy,ys,,s,ys,sy, ...

Modified engine that tracks the states:

As for your question, longer is trivial. Shorter, on the other hand...

State 1: y/123/231/ State 2: y/231/312/ State 3: y/312/123/ State 1: y/123/231/ ...

And with an "initializing" state:

State 1: y/123i/231/ State 2: y/2311/312/ State 3: y/3122/123/ State 4: y/1233/231/ State 2: y/2311/312/
Yes, it has an initializing state. I didn't thought of specifying it because it was transient.

With longer I meant "of longer period", but your examples show us how to actually get any permutation !

Create A New User
Node Status?
node history
Node Type: obfuscated [id://696340]
Approved by ikegami
Front-paged by Arunbear
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2018-08-19 15:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Asked to put a square peg in a round hole, I would:

Results (186 votes). Check out past polls.

Notices?