{The first time I tried to reply to Andrew's message, my mail server
 glitched in a way that seemed to indicate losing my reply.  If this
 is a duplicate, I apologize.}

[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

Aha!  A non-deterministic finite-state automaton written in REBOL!

> == [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 have been so ingenious, I'm almost embarrased to show my
two solutions.

My original version requires just a bit 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

When I gave the hint about "without modifying another variable", I was
actually trying to hint about modifying e.  However, I realized later
that someone might think it was misleading, as I use f and g at the
global level.  To solve that potential objection...

    >> 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

-jn-

Reply via email to