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>
- Do-command