Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Pattern Matching' topicStudent Support Forum > General > Archives > "Pattern Matching"

Next Comment >Help | Reply To Topic
Author Comment/Response
Afshin
02/27/09 00:07am

Pattern matching and passing it in a function, this is my question. Let say i define this variable:

myVar = tag1[tag2[a,b,c,d],tag3[h,y,k]]

Note that tag1, 2 and 3 are simply containers and not functions. For example elements[a,b,c,d] means my element list which contains {a,b,c,d}.

Making a function that takes in myVar, this is what i need:

myFunc[tag1[tag2[x_], tag3[y_]]]:= {x,y}

So in a sense i am extracting the items from my tags. Can anyone tell me why this pattern matching doesn't work when i pass myVar to my function:

My main concern is pattern matching, however this is a simple example. I would appreciate it if you let me know how one would proceed with this.

URL: a.esmaeili@ucalgary.ca,

Subject (listing for 'Pattern Matching')
Author Date Posted
Pattern Matching Afshin 02/27/09 00:07am
Re: Pattern Matching yehuda ben-s... 03/04/09 12:35pm
Next Comment >Help | Reply To Topic