MathGroup Archive 2009

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

Search the Archive

Re: Re: Bug in Pattern Matching with Condition?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97325] Re: [mg97279] Re: Bug in Pattern Matching with Condition?
  • From: dh <dh at metrohm.com>
  • Date: Wed, 11 Mar 2009 04:21:32 -0500 (EST)
  • References: <goqpe7$lrn$1@smc.vnet.net> <goqugt$ngp$1@smc.vnet.net> <200903101032.FAA09839@smc.vnet.net> <1F28FF59-BB99-48DE-8C96-7D7D0393FB5B@mimuw.edu.pl>

Thanks Andrzej. But this still does not explain why "Condition" acts so 
strangely. Is it a bug or feature?
Daniel

Andrzej Kozlowski wrote:
> No, the Varbatim is wrapped around the Head, Condition not around the 
> entire expression. You can do it also with HoldPattern:
> 
> MatchQ[a /; b, HoldPattern[Condition][_, _]]
> True
> 
> Once you hold the Head of the pattern expression it no longer has its 
> special meaning. You can check that Condition behaves is a very special 
> way  when used in a pattern, e.g.
> 
> 
> 
> MatchQ[x, Condition[_, True]]
> True
> 
> MatchQ[x, Condition[_, False]]
> False
> 
> Of course if you replace Condition by Verbatim[Condition] or 
> HoldPattern[Condition] you will always get False.
> 
> 
> Andrzej Kozlowski
> 
> 
> On 10 Mar 2009, at 11:32, dh wrote:
> 
>>
>>
>> Hi Jens,
>>
>> can you elaborate a bit. According to the definition of Verbatim ,
>>
>> Verbatim[Condition][_, _]] should match literally "Condition][_, _]" and
>>
>> not Condition[a, b]. Therefore it looks more like  another bug to me and
>>
>> adds to the mystery of why MatchQ[Condition[a, b], Condition[_, _]]
>>
>> evaluates to False.
>>
>> Daniel
>>
>>
>>
>> Jens-Peer Kuska wrote:
>>
>>> Hi,
>>
>>>
>>
>>> but
>>
>>>
>>
>>> MatchQ[Condition[a, b], Verbatim[Condition][_, _]]
>>
>>>
>>
>>> Regards
>>
>>>   Jens
>>
>>>
>>
>>> cesar wrote:
>>
>>>> Hi Mathematica group, do you get any idea of
>>
>>>> why the following sentences don't give true?
>>
>>>>
>>
>>>> MatchQ[Condition[a, b], Condition[_,_]]
>>
>>>> MatchQ[Condition[a, b], Condition[__]]
>>
>>>> MatchQ[Condition[a, b], HoldPattern[Condition[__]]]
>>
>>>>
>>
>>>> Is this a bug?
>>
>>>>
>>
>>>> Cheers,
>>
>>>> Cesar
>>
>>>>
>>
>>>
>>
>>
>>
> 
> 
> 
> 


-- 

Daniel Huber
Metrohm Ltd.
Oberdorfstr. 68
CH-9100 Herisau
Tel. +41 71 353 8585, Fax +41 71 353 8907
E-Mail:<mailto:dh at metrohm.com>
Internet:<http://www.metrohm.com>



  • Prev by Date: Re: Notebook that auto-executes when opened?
  • Next by Date: Re: Re: Notebook that auto-executes when opened?
  • Previous by thread: Re: Re: Bug in Pattern Matching with Condition?
  • Next by thread: Re: Re: Bug in Pattern Matching with Condition?