MathGroup Archive 2013

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

Search the Archive

Re: apply rule to Partition

  • To: mathgroup at
  • Subject: [mg131694] Re: apply rule to Partition
  • From: Tomas Garza <tgarza10 at>
  • Date: Sat, 21 Sep 2013 04:38:10 -0400 (EDT)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • References: <>

The error message doesn't prevent the evaluation from taking place. In this case it acts more as a warning. You may eliminate this warning using Quiet:
In[1]:= Partition[Range[10],m]/.m->3//QuietOut[2]= {{1,2,3},{4,5,6},{7,8,9}}
Alternatively you can write the ReplaceAll inside the brackets:
In[3]:= Partition[Range[10],m/.m->3]Out[3]= {{1,2,3},{4,5,6},{7,8,9}}
or you can use With:
In[5]:= With[{m=3},Partition[Range[10],m]]Out[5]= {{1,2,3},{4,5,6},{7,8,9}}
In all cases, m has to be a positive integer; otherwise the error actually prevents the evaluation. The definition of Partition doesn't make this explicit but I guess it goes without saying.

> From: jougraw at
> Subject: apply rule to Partition
> To: mathgroup at
> Date: Fri, 20 Sep 2013 07:06:57 -0400
> 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: DDFLink
  • Next by Date: list mutability (very basic question)
  • Previous by thread: Re: apply rule to Partition
  • Next by thread: Re: apply rule to Partition