Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6950
| From | DrMajorBob <btreat1@austin.rr.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: How to get elements satisfying specific condition from a list |
| Date | 2011-12-05 23:47 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jbjl7a$e76$1@smc.vnet.net> (permalink) |
b = Table[{x, y}, {x, 6}, {y, 6}]
Select[Flatten[b, 1], Total@# > 9 &]
{{{1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}}, {{2, 1}, {2,
2}, {2, 3}, {2, 4}, {2, 5}, {2, 6}}, {{3, 1}, {3, 2}, {3, 3}, {3,
4}, {3, 5}, {3, 6}}, {{4, 1}, {4, 2}, {4, 3}, {4, 4}, {4, 5}, {4,
6}}, {{5, 1}, {5, 2}, {5, 3}, {5, 4}, {5, 5}, {5, 6}}, {{6, 1}, {6,
2}, {6, 3}, {6, 4}, {6, 5}, {6, 6}}}
{{4, 6}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}}
or... to get it directly:
Flatten[Table[{x, y}, {x, 6}, {y, 10 - x, 6}], 1]
{{4, 6}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}}
For the second question:
Table[x, {x, 2^2 + 1, 10 - 1}]
{5, 6, 7, 8, 9}
or
n /. Solve[Sqrt[n] > 2 && n < 10, {n}, Integers]
{5, 6, 7, 8, 9}
Bobby
On Sun, 04 Dec 2011 01:51:23 -0600, e-changb <e-changb@hanmail.net> wrote:
> Hi, please help me if you can.. Let
>
> B:= Table[{x, y}, {x, 1, 6}, {y, 1, 6}]
>
> It is clear that B has 36 elements.
>
> I want to get the list of elements satisfying
> 'the first component + second component is bigger than 9'
>
> so that the answer is
>
> {{5,5},{5,6},{6,5},{6,6}}.
>
> In fact, I have no idea for following even simpler problem. : Let A be a
> set of all natural numbers less than 10. Find every element whose squre
> root is bigger than 2. (needless to say the answer is {5,6,7,8,9})
>
> Can you help me ?
>
--
DrMajorBob@yahoo.com
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: How to get elements satisfying specific condition from a list DrMajorBob <btreat1@austin.rr.com> - 2011-12-05 23:47 +0000
csiph-web