Re: Uniform design

*To*: mathgroup at smc.vnet.net*Subject*: [mg48276] Re: Uniform design*From*: ab_def at prontomail.com (Maxim)*Date*: Thu, 20 May 2004 04:03:56 -0400 (EDT)*References*: <c7nnc7$dm5$1@smc.vnet.net> <200405130408.AAA26737@smc.vnet.net> <c81has$4rj$1@smc.vnet.net> <200405150756.DAA00995@smc.vnet.net> <c89pfb$t0e$1@smc.vnet.net> <c8ci8i$etv$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Here's another issue that I think belongs to this thread: it's interesting to consider how well Table/Sum double as both mathematical and programming constructs. They work like Block to make possible things like y=x;Table[y,{x,5}], but how well is this approach suited for programming? Suppose we're writing something like f[L_]:=Table[L[[i]],{i,Length@L}] to get the list of elements of L (a clumsy way to write List@@L); then everything works fine until we try f[{i,j}]. So for programming this block-like behaviour is more like a hidden hazard; it works well only if we know the structure of L in advance. Instead, what is needed here is a Table/Sum with a local (unique) iterator; otherwise we need to wrap every Table/Sum in Module or put it in a separate context. Besides, there's a matter of 'optimizations' that Mathematica uses for Sum (an issue which was discussed in this newsgroup a while ago): In[1]:= Module[{cnt = 0}, Sum[cnt += 1, {i, 10^6}] ] Module[{cnt = 0}, Sum[cnt += 1, {i, 10^6 + 1}] ] Out[1]= 500000500000 Out[2]= 1000001 When using Sum as a programming construct, probably the last thing user needs is to see it unexpectedly change behaviour after reaching some internal threshold. Maxim Rytin m.r at prontomail.com

**References**:**Re: Uniform design***From:*ab_def@prontomail.com (Maxim)

**Re: Uniform design***From:*ab_def@prontomail.com (Maxim)