On Wed, Aug 16, 2000 at 08:26:26AM +1000, Jeremy Howard wrote:
> Doesn't RFC 82 (Make operators behave consistantly in a list context)
> provide this functionality? This is perfectly valid under that proposal:
> 
>   @result = @a || @b;
> 
> Which applies '||' component-wise to elements of @a and @b, placing the
> result in @result.
> 
> I'm no Prolog guru, so feel free to correct me if I'm missing something
> here.

I think you're missing the backtracking part (I'm no guru either).
As I understand things:

        BLOCK1 andthen BLOCK2

evaluates BLOCK1 and then if BLOCK1 evaluates to "true" evaluates
BLOCK2.  If BLOCK2 evaluates to "true" we're done.  If BLOCK2
evaluates to "false", then BLOCK1 is re-evaluated.  Er, let me see if
I can write the logic better:

        1. eval BLOCK1
        2. if "false", stop, else goto 3
        3. eval BLOCK2
        4. if "true", stop, else goto 1

It's kind of an all-or-nothing expression with side effects
(evaluating the blocks).  This sort of logic can be extended to N
blocks too.

Though I think if we're going to support backtracking like this, we'll
need to support the cut operator as well  (! in prolog)

(Note the only prolog I've done was about 10 years ago for about 2 weeks
and about 2 years ago for 2 or 3 weeks in a programming languages class
at a university)

-Scott
-- 
Jonathan Scott Duff
[EMAIL PROTECTED]

Reply via email to