MathGroup Archive 2011

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

Search the Archive

Re: How to roll up multiple Line calls into a loop

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118342] Re: How to roll up multiple Line calls into a loop
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Sat, 23 Apr 2011 07:50:11 -0400 (EDT)

On 4/22/11 at 5:41 AM, sol.lederman at gmail.com (Sol Lederman) wrote:

>I'm new to Mathematica.

>I have the following bit of graphics:

>Graphics[{
>Line[{{0, 10}, {1, 0}}],
>Line[{{0, 9}, {2, 0}}],
>Line[{{0, 8}, {3, 0}}],
>Line[{{0, 7}, {4, 0}}],
>Line[{{0, 6}, {5, 0}}],
>Line[{{0, 5}, {6, 0}}],
>Line[{{0, 4}, {7, 0}}],
>Line[{{0, 3}, {8, 0}}],
>Line[{{0, 2}, {9, 0}}],
>Line[{{0, 1}, {10, 0}}],
>}]

>I want to simplify it to do some sort of iteration to compute the
>end points of the lines. I can do this easily in a variety of
>procedural languages but I haven't yet grokked how Mathematica would
>do this.

It is unclear to me what you want as the end result. I am
guessing you want the arguments to Line converted to a list. If
so, a list of Lines (the argument to Graphics) can be converted
as follows:

In[2]:= List @@@ {Line[{{0, 10}, {1, 0}}], Line[{{0, 9}, {2, 0}}],
   Line[{{0, 8}, {3, 0}}], Line[{{0, 7}, {4, 0}}],
   Line[{{0, 6}, {5, 0}}], Line[{{0, 5}, {6, 0}}],
   Line[{{0, 4}, {7, 0}}], Line[{{0, 3}, {8, 0}}],
   Line[{{0, 2}, {9, 0}}], Line[{{0, 1}, {10, 0}}]}

Out[2]= {{{{0, 10}, {1, 0}}}, {{{0, 9}, {2, 0}}}, {{{0, 8}, {3,
     0}}},
    {{{0, 7}, {4, 0}}}, {{{0, 6}, {5, 0}}}, {{{0, 5}, {6, 0}}},
    {{{0, 4}, {7, 0}}}, {{{0, 3}, {8, 0}}}, {{{0, 2}, {9, 0}}},
    {{{0, 1}, {10, 0}}}}



  • Prev by Date: Derivative of BernsteinBasis functions
  • Next by Date: Re: How to roll up multiple Line calls into a loop
  • Previous by thread: Re: How to roll up multiple Line calls into a loop
  • Next by thread: Re: How to roll up multiple Line calls into a loop