Re: Pattern example
- To: mathgroup at smc.vnet.net
- Subject: [mg19312] Re: Pattern example
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Sat, 14 Aug 1999 23:42:46 -0400
- References: <7p2vem$ajd@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Chris,
Extra list brackets crept in in the last example:
{{1 + a}, {2 + a}, {3 + a}} /. {t_} -> c
{c, c, c}
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565
chris <senisen at ptty.loxinfo.co.th> wrote in message
news:7p2vem$ajd at smc.vnet.net...
> I am trying to learn how to use patterns and replacements,
> for instance this example:
>
> {{1+a},{2+a},{3+a}} /. {t_+a}->c
> {c,c,c}
>
> FullForm[{{1+a},{2+a},{3+a}} /. {t_+a}->c]
> FullForm= List[c,c,c]
>
> So far so good
>
> Then
> {{1+a},{2+a},{3+a}} /. t_->c
> c
> this is no more a list, but
>
> FullForm[{{1+a},{2+a},{3+a}} /. {t_}->c]
> List[c,c,c]
> shows it as a list
>
> What is behind this difference?
>
> Chris
>