Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Redudant code for style purposes?
Replies: 2   Last Post: Apr 14, 2014 5:26 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Murray Eisenberg

Posts: 2,105
Registered: 12/6/04
Re: Redudant code for style purposes?
Posted: Apr 14, 2014 5:26 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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 246-7240 (H)
University of Massachusetts
710 North Pleasant Street
Amherst, MA 01003-9305










Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.