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

MathGroup Archive 2009

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

Search the Archive

Re: Do-command

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102642] Re: [mg102588] Do-command
  • From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
  • Date: Mon, 17 Aug 2009 04:06:53 -0400 (EDT)
  • References: <200908161038.GAA01118@smc.vnet.net>

Hi,

Do-Loops don't print, collect or return anything you do inside.
They just *evaluate* the expression and per default the return-value of
a Do-loop is Null. What you want is

res = {};
Do[AppendTo[res, Select[{1, 2, 4, 7, 6, 2}, # >= i &]], {i, 7}];
res

or

Table[Select[{1, 2, 4, 7, 6, 2}, # >= i &], {i, 7}]

or

Array[
 Function[{val}, Select[{1, 2, 4, 7, 6, 2}, (# >= val &)]], 7]

or

Function[{val}, Select[{1, 2, 4, 7, 6, 2}, (# >= val &)]] /@ Range[7]


Cheers
Patrick

On Sun, 2009-08-16 at 06:38 -0400, Uwe Gotzes wrote:
> Hi!
> 
> Can anybody tell, why
> Do[Select[{1, 2, 4, 7, 6, 2}, # >= i &], {i, 7}]
> does not produce output in Mathematica?
> 



  • References:
    • Do-command
      • From: Uwe Gotzes <u.gotzes@googlemail.com>
  • Prev by Date: histograms, logarithmic
  • Next by Date: Re: Generating a list numnber in string format
  • Previous by thread: Re: Do-command
  • Next by thread: Re: Do-command