"for" question (newbie)

Bill Spight bspight at pacbell.net
Thu Sep 12 18:40:43 CEST 2002


Hi, guys!

I appreciate all the Oz documentation that you provide. Many thanks. :-)

I am confused about this loop ("Concurrent Constraint Programming in Oz
for Natural Language Processing, p. 19). 


for
  X in L
  Y in {Tail L}
do
 (X<Y)=true
end

L is a list of integers (not necessarily instantiated).

At first glance, and upon checking the documentation, it seems like the
loop should traverse the cartesian product of L and its tail. E. g.,
suppose

L = [1 2 3]

we should have

X = 1 Y = 2
X = 1 Y = 3
X = 2 Y = 2
X = 2 Y = 3
X = 3 Y = 2
X = 3 Y = 3

in which case (2<2) will fail to unify with true.

But that is not apparently what is happening. I'm confused. 

Could someone please explain?

Many thanks,

Bill Spight

P. S. Full code:

declare
N=6
fun {Tail _|L} L
proc {GenerateAndTest L}
    L={MakeList N}
    L ::: 1#N
    {FD.distribute naive L}
    for
       X in L
       Y in {Tail L}
    do
       (X<Y)=true
    end
end
-
Please send submissions to users at mozart-oz.org
and administriva mail to users-request at mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.





More information about the mozart-users mailing list