Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2013

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

Search the Archive

Re: apply rule to Partition

  • To: mathgroup at smc.vnet.net
  • Subject: [mg131702] Re: apply rule to Partition
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Sat, 21 Sep 2013 04:40: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: <20130920110657.874FE69E8@smc.vnet.net>

Partition[Range[10], m /. m -> 2]


{{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}}


With[{n = 10, m = 2}, Partition[Range[n], m]]


{{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}}


Module[{n = 10, m = 2}, Partition[Range[n], m]]


{{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}}


Block[{n = 10, m = 2}, Partition[Range[n], m]]


{{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}}


Hold[Partition[Range[n], m]] /. {n -> 10, m -> 2} // ReleaseHold


{{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}}



Bob Hanlon




On Fri, Sep 20, 2013 at 7:06 AM, Joug Raw <jougraw at gmail.com> wrote:

>
> I want to use rule to simplify my code. A piece of my code use Partition
> and I tried something like:
>
> Partition[Range[10], m] /. m -> 2
>
> It give me error message. My real code is in fact more complicated and this
> way failed to give me an output. How could I make it work?
> Thanks.
>
>
>




  • Prev by Date: Re: apply rule to Partition
  • Next by Date: Re: plotting integrals
  • Previous by thread: Re: apply rule to Partition
  • Next by thread: Extract columns based on their the title in header