%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Computes the set S of the squares of all numbers contained
% in a set I
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
squares(I,S) :-
S = {Y : exists(X, X in I & Y is X * X)}!.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Sample goals:
%
% {log}=> squares({2,3,4},S).
% S = {4,9.16}
%
% {log}=> squares(int(1,10),S).
% S = {1,4,9,16,25,36,49,64,81,100}