Re: Help Please with numbers
- Posted by Jason Gade <jaygade at yahoo.com> Aug 02, 2005
- 581 views
cklester wrote: > > Jason, I agree with the definition you've provided below... with some notes: > > > sum > > > > Syntax: x2 = sum(x1) > > Can we use 's'-prefixed variables to indicate sequences? Otherwise, you'll > have to explicity state what types of parameters the function > receives/returns. Actually I was referring the Euphoria documentation and used RDS style straight from sqrt(). I know we agreed to at least do this differently but I was just responding quickly. > > s2 = sum(s1) > a1 = 1.2 * 6.5 > i1 = 3 + 8 > for c=1 to 10 -- 'c' is a 'counter' > > > Comments: This function may be applied to a single level sequence or a > > multi-level > > sequence. In the case of a mult-level sequence, all elements must be atoms > > or sequences > > with the same length. > > > > This function is useful for adding up a list of numbers of unknown length. > > > > Example 1:}}} <eucode>x = sum({1, 3, 5, 7, 9}) > > > > Example 2:}}} <eucode>x = sum({1, 2, 3}, 4, {5, 6, 7}) > > Example 3:}}} <eucode>x = sum({49, 50, 51}, {52, 53}) > > You probably meant > > Example 2: x = sum({{1, 2, 3}, 4, {5, 6, 7}}) > Example 3: x = sum({{49, 50, 51}, {52, 53}}) > > unless Euphoria has variable parameters now!!! :) Yes, that is why specifications should be proofread *before* actually writing code> > > Anyway, at first ck's suggestion seemed reasonable and I could'nt > > *completely* poke > > a hole in it. > > It's not reasonable for a "standard Euphoria" library, but maybe for the > sum.e include file. :) > > -=ck > "Programming in a state of EUPHORIA." > http://www.cklester.com/euphoria/ > ===================================== Too many freaks, not enough circuses. j.