
Re: Redudant code for style purposes?
Posted:
Apr 14, 2014 5:26 AM


Correct, the "List @@ " is redundant there. Moreover, if you use the entire original list "array" that is, if you change the Table expression to
Table[array[[i ;; i + 1]], {i, 1, 19}]]
, then there's no need to use indexing or Table at all, just Partition with a third argument to indicate overlap:
arr = RandomReal[{0, 10}, 20]; Partition[arr, 2, 1]
On Apr 13, 2014, at 5:27 AM, andymhancock@gmail.com wrote:
> The Mathematica Cookbook has an example: > > array = RandomReal[{0, 10}, 20] > Table[List @@ array[[i ;; i + 1]], {i, 1, 16}] > > I'm new to Mathematica, but to me, the "List @@" seems redundant. The > statements give the same results if I remove it. Is there a reason > for this, either functionally or for clarity? >
Murray Eisenberg murray@math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 240 2467240 (H) University of Massachusetts 710 North Pleasant Street Amherst, MA 010039305

