Re: Help Please with numbers
- Posted by Jason Gade <jaygade at yahoo.com> Aug 01, 2005
- 598 views
Jason Gade wrote: > > cklester wrote: > > > > Jason Gade wrote: > > > Jason Gade wrote: > > > > cklester wrote: > > > > > This is an argument for ESL's sum() function being able to handle all > > > > > types... > > > > > sequence r1, r2 > > > > > integer r3, r4 > > > > > atom total > > > > > r1 = getText(EditText20) > > > > > r2 = getText(Edittext21) > > > > > r3 = 34 > > > > > r4 = 15 > > > > > total = sum({r1,r2}) > > > > > total += sum({r3,r4}) > > > > > > Oops, sorry. I guess that you meant that r1 and r2 are text > > > representations of numbers. > > > How would sum know that? > > > > It's gonna hafta be smart about it! > > > > r1 = "123" > > r2 = 456 > > total = sum({r1,r2}) -- can work since element 1 is a sequence, use value() > > > > -=ck > > "Programming in a state of EUPHORIA." So I'm trying to think of a reason why this would be a bad idea, and I can't do it. The only valid reason I could come up with is that no other Euphoria routine acts this way (that I know of). That isn't really a valid argument though. Since sum shouldn't be infinitely recursive (maybe recursive_sum() could be a different function...) keying on whether top-level elements are sequences is a good idea. Even if we make s string library like I propose that has packed strings and Unicode strings, an ESL version of value() should be able to differentiate. Hmmm. ===================================== Too many freaks, not enough circuses. j.