List comprehensions: Difference between revisions

Content added Content deleted
Line 744: Line 744:
Examples of use :<BR>
Examples of use :<BR>
List of Pythagorean triples :
List of Pythagorean triples :
<pre> ?- V <- {X, Y, Z & X <- 1..20, Y <- 1..20, Z <- 1..20 & X < Y, Y < Z, X*X+Y*Y =:= Z*Z}.
<pre> ?- V <- {X, Y, Z & X <- 1..20, Y <- X..20, Z <- Y..20 & X*X+Y*Y =:= Z*Z}.
V = [ (3,4,5), (5,12,13), (6,8,10), (8,15,17), (9,12,15), (12,16,20)] ;
V = [ (3,4,5), (5,12,13), (6,8,10), (8,15,17), (9,12,15), (12,16,20)] ;
false.
false.