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

MathGroup Archive 2007

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

Search the Archive

Re: Select[ ] Woes

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83163] Re: [mg83126] Select[ ] Woes
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Tue, 13 Nov 2007 03:43:37 -0500 (EST)
  • References: <200711121013.FAA11004@smc.vnet.net> <9F632F2D-BF18-4433-901C-E20C5B2E28CF@mimuw.edu.pl> <F87482A0-B679-4B88-94FE-A6FE01DBECE2@mimuw.edu.pl>

On 12 Nov 2007, at 21:35, Andrzej Kozlowski wrote:

>
> On 12 Nov 2007, at 21:14, Andrzej Kozlowski wrote:
>
>>
>> On 12 Nov 2007, at 19:13, Bruce Colletti wrote:
>>
>>> Re 6.0.1 under WinXP.
>>>
>>> What's wrong with the Select statement?  x is clearly a list of  
>>> positive rationals, yet none are returned.  The fragment is  
>>> extracted from larger code.
>>>
>>> Thankx.
>>>
>>> Bruce
>>>
>>> ...
>>> Print@x;
>>> Print@Select[x, # > 0 &];
>>> ...
>>>
>>> {20400/12,25200/9,12000/6}
>>>
>>> {}
>>>
>>
>>
>> It seems clear that your list x is not a list of numbers, since in  
>> Mathematica you can't get an output like 12000/6 but instead you  
>> will always get:
>>
>> 12000/6
>> 2000
>>
>> This suggests that the objects at level 2 in x are not numbers,  
>> perhaps they are strings or things like HoldForm[12000/6]. In the  
>> latter case you could use:
>>
>> Cases[x, z_ /; z > 0, Infinity]
>>
>> Of course this won't work if the "numbers" are really strings.
>>
>> Andrzej Kozlowski
>
> Sorry, the Cases suggestion was wrong. Suppose your list is actually:
>
> x = {HoldForm[2400/12], HoldForm[25200/9], HoldForm[12000/6]};
>
> Then using Cases as above will give you more than you want:
>
>  Cases[x, z_ /; z > 0, Infinity]
> {2400, 12, 1/12, 200, 25200, 9, 1/9, 2800, 12000, 6,
>    1/6, 2000}
>
> which is not what you wanted. In any case, whatever you have in  
> your list can't have the head HoldForm as that is always visible in  
> InputForm. So there is something very weird about your problem. I  
> now suspect that the elements of x are strings. For example:
>
> x = {"2400/12", "25200/9", "12000/6"}
>
> then
>
> Print@x
> {2400/12, 25200/9, 12000/6}
>
> (in output form)
>
> which is,of course,, highly mnisleading  since the list members are  
> not numbers.
>
> By the way, was this supposed to be some king of "puzzle" or a joke?
>
> ANdrzej Kozlowski
>
>
>

Oh, sorry. I sent both of my posts before I saw your second one.

Andrzej Kozlowski



  • References:
  • Prev by Date: Re: Zoom2D and GetGraphicsCoordinates palettes combined
  • Next by Date: RE: Zoom2D and GetGraphicsCoordinates palettes combined
  • Previous by thread: Re: Select[ ] Woes
  • Next by thread: Select[ ] Woes: ÃÂÃÂSolved