hi Rosemary,

have you used the :word notation for the variable in your path
(think of it as getting the value out of the word
    instead of putting it in)

repeat i 4[
     either equal? ans/:i target/:i
         [bulls: bulls + 1]
         [shots: shots + 1]
]


Rosemary de Dear wrote:
> Hello Rebol-Org,
> 
> I am having a problem trying to "shrink" some code. These are the initial=
>  =20
> values -
> 
> random/seed now
> digits: [1 2 3 4 5 6 7 8 9 0]
> target: copy []
> 
> ;;; then target becomes a fairly random 4-digit number
> target: to-string random/secure digits
> remove/part target 6
> 
> I want to compare the target with the user's answer, but I can't make a =20
> for or repeat loop
> work
> because I get invalid path errors. Even though it returns approptiate =20
> results, what follows
> is
> obviously inefficient so I would be very glad to know the way to make it =
> =20
> leaner.
> 
> Regards, Rosemary
> 
> 
> get-answer: does [
> ans: to-string num/text
> answer: copy []
> bulls: shots: 0
> 
> if find target ans/1 [
> either ans/1 =3D=3D target/1
> [bulls: bulls + 1] [shots: shots + 1]]
> 
> if find target ans/2 [
> either ans/2 =3D=3D target/2
> [bulls: bulls + 1][shots: shots + 1]]
> 
> if find target ans/3 [
> either ans/3 =3D=3D target/3
> [bulls: bulls + 1][shots: shots + 1]]
> 
> if find target ans/4 [
> either ans/4 =3D=3D target/4
> [bulls: bulls + 1][shots: shots + 1]]
> 
> tries: tries + 1
> either ( tries <=3D 9 )
> [answer: rejoin ["0" tries ": " ans "   " bulls "     " shots]]
> [answer: rejoin [tries ":  " ans "   " bulls "     " shots]]
> ]
> 
> 
> --=20
> 
> Formix Australia - www.formix.com.au
> 
> 613 9354 9585
> PO Box 261 Nth Carlton Vic 3054

-- 
           ... nice weather     eh          [EMAIL PROTECTED]
-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to