Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1996
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

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