MathGroup Archive 2002

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

Search the Archive

RE: Stumped again on a simple list

  • To: mathgroup at
  • Subject: [mg32815] RE: [mg32795] Stumped again on a simple list
  • From: "David Park" <djmp at>
  • Date: Thu, 14 Feb 2002 01:43:32 -0500 (EST)
  • Sender: owner-wri-mathgroup at


Use your If statement as a pure function and Map it onto the list. This is
the kind of thing that pure functions are great for. As a little extra, I
also counted the number of elements less than 100 and greater than 100. The
list is already in order so just use Split to break it into two lists, one
with all the 50's and the other with all the 200's. Then Map Length onto the
new array to get the count.

ii = Table[z, {z, 50, 1400, 5}];

jj = If[# < 100, 50, 200] & /@ ii;
Length /@ Split[jj]
{10, 261}

David Park
djmp at

> From: 1.156 [mailto:rob at]
To: mathgroup at
> Greetings cypherers all,
> I make a simple list ii and I find I can make other lists easily
> by algebraic moves like
> jj=ii/2, etc.  But when I want make a new list which splits two
> different formula, I'm stumped.
> Here's a stripped down version to illustrate my problem.  I want
> to use the value in the original
> array to determine how to make the new array.  The If[] is the
> only thing I can find to make
> this decision.  But, it seems I'm not even close when I try:
> ii=Table[z,{z,50,1400,5}];
> jj=If[ii<100,50,200]
> I've looked around a good bit but have not stumbled into any
> topic that appears to bear on this problem.
> Can I please ask a kind soul to (again) point me in the right direction?
> Thanks, Rob

  • Prev by Date: Re: Stumped again on a simple list
  • Next by Date: Linebreaks and style when saving as TeX
  • Previous by thread: Re: Stumped again on a simple list
  • Next by thread: Re: Stumped again on a simple list