Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Pattern matching
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Reinhard Simonovits

Posts: 1
Registered: 12/11/04
Pattern matching
Posted: Sep 26, 1996 10:10 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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








Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.