MathGroup Archive 1996

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

Search the Archive

Pattern matching

  • To: mathgroup at smc.vnet.net
  • Subject: [mg4881] Pattern matching
  • From: xharkrvs at mbox.tu-graz.ac.at (Reinhard Simonovits)
  • Date: Thu, 26 Sep 1996 22:42:31 -0400
  • Organization: Graz University of Technology, Austria
  • Sender: owner-wri-mathgroup at wolfram.com

Dear Mathgroupers,
In  the list of two dim vectors  vecs = {   { {-1,1}, {2,2} },   {3,4}  }   in a rectangular coord systems,  the last
vector is a radius vector.  
To plot them I have to add {0,0}, so that plotvecs = {    { {-1,1}, {2,2} },   { {0,0}, {3,4} }   } fulfills the task.

This can be done with
plotvecs = Apply[    If[ NumberQ[#1],     { {0,0}, {##} },      {#1,#2} ]&,   vecs,  {1}  ]

I wonder how could this be done by pattern matching.

plotvecs =  vecs /. {a_,b_} -> { {0,0},{a,b} } /; ???

Thanks in advance, Reinhard


==== [MESSAGE SEPARATOR] ====


  • Prev by Date: [bug!] ListPlotVectorField[]
  • Next by Date: list splitting
  • Previous by thread: [bug!] ListPlotVectorField[]
  • Next by thread: list splitting