[eclipse-clp-users] product of a list of expressions

From: liu.yu.senior.china <liu.yu.senior.china_at_...6...>
Date: Mon, 14 Sep 2009 22:17:58 -0600
Dear all,

I don't find any predicate to calculate the product of a list directly. I use the following code to calculate the product of a list.

A=[E1,E2,E3,E4],
dim(Pr,[4]),
( for(K,1,4),
foreach(Ai,A),
foreachelem(Pi,Pr),
param(A,Pr)
do
((K==1)->(Pi = Ai);(Pi = Pr[K-1]*Ai))
).

If it is a list of constants and I use 'is/2' in the if else statement, then everything works well. However, if it is a list of expression, then it is not working and I get a huge Pr. It seems to fall into a wrong recursion. I need the product of the list to build a constraint. Any suggestion is appreciated.

Best,

Liu, Yu


2009-09-14 



liu.yu.senior.china 
Received on Tue Sep 15 2009 - 03:18:18 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 16 2024 - 09:13:20 CEST