MathGroup Archive 1999

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

Search the Archive

Pattern example


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


  • Prev by Date: Multiple html links
  • Next by Date: Re: circumference of an ellipse
  • Previous by thread: Multiple html links
  • Next by thread: Re: Pattern example