Hi, Is this fast/easy enough for you? % product(+ExprList, -Result) product(ExprList, Result) :- ( foreach(Expr, ExprList), fromto(1, In, Out, Result) do Out is In * eval(Expr) ). ?- product([1, 2, 3], X). X = 6 ?- product([1+1, 2+2, 3+3], X). X = 48 Sergii. On Wed, Feb 27, 2013 at 12:50 PM, Martin Michalowski <martin.michalowski_at_adventiumlabs.com> wrote: > Is there an equivalent built-in predicate for sum(+ExprList, -Result) that evaluates the arithmetic expressions in ExprList and unifies their product with Result? If not, do people have a fast/easy way of generating the product of a list? I know the times predicate is available but I'm hoping to avoid iterating over multiple instances of it. > > Best, > Martin > > -- > Martin Michalowski, Ph.D. > Principal Research Scientist, Adventium Labs > martin.michalowski_at_adventiumlabs.com > http://www.adventiumlabs.com/staff/martin-michalowski > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_feb > _______________________________________________ > ECLiPSe-CLP-Users mailing list > ECLiPSe-CLP-Users_at_lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/eclipse-clp-usersReceived on Wed Feb 27 2013 - 22:05:57 CET
This archive was generated by hypermail 2.2.0 : Thu Feb 28 2013 - 18:13:18 CET