Rebol Talk Forum  |  Getting Started  |  Code Examples, Tips & Advice  |  Topic: REBOL (Until)
Pages: [1] Print
Author Topic: REBOL (Until)  (Read 679 times)
DefiantPc
Administrator
Jr. Member
*
Offline Offline

Posts: 70


View Profile
REBOL (Until)
« on: February 09, 2004, 11:06:34 PM »

Ok.  I know alot of guys are new to this list so I thought I would post something that was confusing to me when I started with REBOL.  Ever look at the help for 'until:

>> help until
USAGE:
    UNTIL block

DESCRIPTION:
     Evaluates a block until it is TRUE.
     UNTIL is a native value.

ARGUMENTS:
     block -- (Type: block)

So what does this actually mean.  Does this mean we return a value and what if we have 100 lines of code in 'until evaluation block.  This was confusing for me having never really did programming before REBOL.  So the easy answer is the last value that is TRUE will end the loop.  Try yourself by just playing with values in the until eval block.

until [true true false]

until [false true true]

until [true false]

until [true true]

As you can see whatever the last item in the block evaluates to determines the outcome of the loop.  

Hope this helps as I was a bit confused at how to use this great function early on.

Thanks to, Paul Tretter.

 
Logged
CarlRead
Full Member
***
Offline Offline

Posts: 106


View Profile
REBOL (Until)
« Reply #1 on: February 10, 2004, 02:56:31 AM »

Other languages often use REPEAT UNTIL, used either like this...
Code:
REPEAT UNTIL condition true
   code...
END REPEAT
or this...
Code:
REPEAT
   code
UNTIL condition true
That's not an ideal way for a functional language such as REBOL to work though, hence UNTIL [code... condition true].  A nice by-product of this is the need for less code.

On a related note, REBOL originally allowed an ELSE function to follow an IF. ie...
Code:
IF condition true [do this]
ELSE [do this instead]
but it's not a very REBOL way to do things, as a REPEAT UNTIL wouldn't be, so it's been replaced by IF/ELSE or EITHER.  (Take your pick, though EITHER's the recomended choice.)  If you look at the HELP for ELSE now you'll see it's classed as obsolete.
Logged

- Carl Read
Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Code Examples, Tips & Advice  |  Topic: REBOL (Until)
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 17, 2008, 05:43:02 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2169 Posts in 562 Topics by 1224 Members
Latest Member: thyptoste

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc