Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7008

Re: How to get elements satisfying specific condition froma

From Barrie Stokes <Barrie.Stokes@newcastle.edu.au>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: How to get elements satisfying specific condition froma
Date 2011-12-08 10:21 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jbq32c$ibg$1@smc.vnet.net> (permalink)

Show all headers | View raw


Hi Tomas,

I like the new notation for Function, and it's a little less @@#$%^& looking than (stuff with #)&.

 t = Table[ {x, y}, {x, 1, 6}, {y, 1, 6} ]
Select[ Partition[ Flatten[ t ], 2 ], (s \[Function] \!\(\*SubscriptBox[\(s\), \(\(\[LeftDoubleBracket]\)\(1\)\(\
\[RightDoubleBracket]\)\)]\) + \!\(\*SubscriptBox[\(s\), \(\(\[LeftDoubleBracket]\)\(2\)\(\
\[RightDoubleBracket]\)\)]\) > 9) ]
Select[ Partition[ Flatten[ t ], 2 ], (s \[Function] \!\(\*SubscriptBox[\(s\), \(\(\[LeftDoubleBracket]\)\(1\)\(\
\[RightDoubleBracket]\)\)]\) == \!\(\*SubscriptBox[\(s\), \(\(\[LeftDoubleBracket]\)\(2\)\(\
\[RightDoubleBracket]\)\)]\) + 1) ]
Select[ Partition[ Flatten[ t ], 2 ], (s \[Function] \!\(\*SubscriptBox[\(s\), \(\(\[LeftDoubleBracket]\)\(1\)\(\
\[RightDoubleBracket]\)\)]\) / \!\(\*SubscriptBox[\(s\), \(\(\[LeftDoubleBracket]\)\(2\)\(\
\[RightDoubleBracket]\)\)]\) <= 1) ]

OK, it looks horrible in an email, but quite neat in the Notebook.

Barrie

>>> On 05/12/2011 at 9:14 pm, in message <201112051014.FAA04838@smc.vnet.net>,
Tomas Garza <tgarza10@msn.com> wrote:
> I'm sure I can, and I suggest that you spend a couple of weeks studying the 
> very basics of Mathematica.
> Now, first, don't use capitalized letters to name variables (so as to avoid 
> possible conflicts with Mathematica's own symbols).Second, it's not necessary 
> to use B:= in your definition of B (:= means "SetDelayed"; a simple "Set" = 
> would be enough).Third, you are wrong in the first problem; the answer is not 
> {{5,5},{5,6},{6,5},{6,6}}.
> Then, you may use the following:
> t = Table[{x, y}, {x, 1, 6}, {y, 1, 6}];Select[Partition[Flatten[t], 2], 
> #[[1]] + #[[2]] > 9 &]{{4, 6}, {5, 5}, {5, 6}, {6, 4}, {6, 5}, {6, 6}}
> i = Range[9]{1, 2, 3, 4, 5, 6, 7, 8, 9}Select[i, Sqrt[#] > 2 &]{5, 6, 7, 8, 9}
> -Tomas
> 
>> Date: Sun, 4 Dec 2011 02:51:23 -0500
>> From: e-changb@hanmail.net 
>> Subject: How to get elements satisfying specific condition from a list
>> To: mathgroup@smc.vnet.net 
>>
>> 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 ?
>>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: How to get elements satisfying specific condition froma Barrie Stokes <Barrie.Stokes@newcastle.edu.au> - 2011-12-08 10:21 +0000

csiph-web