[EMAIL PROTECTED] wrote:
> 
> >> e: ['e pick ['f 'g] random length? third e]
> == ['e pick ['f 'g] random length? third e]
> >> print e
> e f
> >> print e
> e g
> >> print e
> e g
> >> print e
> e g
> >> print e
> e f
> 
> Not quite the same, but on occasion I will get the same result! :-)
>

A non-deterministic finite state automaton!  ;-)

> 
> This is better:
> 
> >> e
> == [reduce replace [#"e" #"f" + 1] last third e to-integer even? last
> third e]
> >> print e
> e f
> >> e
> == [reduce replace [#"e" #"f" + 0] last third e to-integer even? last
> third e]
> 

You guys are so ingenious, I'm almost too embarassed to show my
original solution now!

Anyway, it takes just a tad of set-up...

    >> f: [e: g]
    == [e: g]
    >> g: [e: f]
    == [e: f]
    >> e: f
    == [e: g]

after which...

    >> print e
    e f
    >> print e
    e g
    >> print e
    e f
    >> print e
    e g

If someone feels it was misleading when I said "without modifying
another variable" (although I was really trying to give a hint
about modifying e, since I said "another" variable), then I'd have
to rewrite this as:

    >> e: use [f g] [f: [e: g] g: [e: f] f]
    == [e: g]
    >> print e
    e f
    >> print e
    e g
    >> print e
    e f
    >> f: "uninvolved global variable"
    == "uninvolved global variable"
    >> g: "another innocent bystander"
    == "another innocent bystander"
    >> print e
    e g
    >> print e
    e f
    >> print e
    e g

-jn-

Reply via email to