Re: Help Please with numbers

new topic     » goto parent     » topic index » view thread      » older message » newer message

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.

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!!! :)

> 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/

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu