Re: Conditonal sum
- To: mathgroup at smc.vnet.net
- Subject: [mg50269] Re: [mg50263] Conditonal sum
- From: "David Park" <djmp at earthlink.net>
- Date: Tue, 24 Aug 2004 06:22:03 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Christopher, Is this what you mean? Sm = {1, 3, 4, 7, 11}; a + Plus @@ Sm 26 + a or Fold[Plus, a, Sm] 26 + a David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Christopher Grinde [mailto:christopher.grinde at hive.no] To: mathgroup at smc.vnet.net I am new to mathematica and could really need a tip on how to implement a conditional sum. Pseudocode would be something like this EndSum=a; if j in Sm: EndSum=EndSum+f[j] end I have tried doing this by using an If-clause inside the sum-function, but this seems little elegant and is nor very suitable for symbolic calculations. Any advice would be highly appreciated Christopher Grinde