MathGroup Archive 2014

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Redudant code for style purposes?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132578] Re: Redudant code for style purposes?
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Mon, 14 Apr 2014 05:25:50 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <20140413092737.B651E6A38@smc.vnet.net>

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









  • Prev by Date: Redudant code for style purposes?
  • Next by Date: Re: Redudant code for style purposes?
  • Previous by thread: Redudant code for style purposes?
  • Next by thread: Re: Redudant code for style purposes?