1: my cycle-words definition works until I attempt to move back to the front
of the sequence... thus I need some sort of fix to the first clause of my
cycle-words defn

2: I think it is un-necessarily redundant to recode the binding of guess to
the output of an ask, but, reform appears to fail in this respect. Can
anyone help optimize away that guess: ask "What is the secret word?" in the
body of the while loop?

REBOL [
    Title:  "More than one secret word (sequential cycle)"
    Date:   11-Oct-99
    Author: "T.M. Brannon"
    Email:  [EMAIL PROTECTED]
    File:   %more-than-one-word-2.r
    Purpose:    {
        Play a guessing game
    }
    Category: [file script utility]
]


secret-words: [ "camel" "llama" "oyster" ]
cycle-words: [ either tail? secret-words
  [ secret-words: head secret-words ]
  [ secret-words: next secret-words ]
  first secret-words ]

; this works, but I find it klunky
index: 0
cycle-words3: [ either equal? index length? secret-words
  [  index: 1         ]
  [  index: index + 1 ]
       pick secret-words index ]

name:  ask "What is your name? "
guess: ask "What is the secret word? "

either equal? name "Randal"
 [ print "Hi Randal! No secret word required. You're the greatest!" ]
 [ print [ join "Hello " name "." ]
   while [not equal? reform guess do cycle-words]
  [ print rejoin [ guess " is not a correct guess." ]
    guess: ask "What is the secret word? " ]
        print "That's it!!!! You got it!!!" ]


Reply via email to