Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'applying transformation rules to table' topicStudent Support Forum > General > Archives > "applying transformation rules to table"

Next Comment >Help | Reply To Topic
Author Comment/Response
Laura
08/23/10 10:47am

I have generated table comStr as follows:

marStr := {"M", "P"}
traStr := {"V", "D", "S", "I"}
patStr := {"L", "H", "A", "N"}
malStr = Tuples[{marStr, traStr}]
femStr = Tuples[{marStr, patStr}]
comStr = Table[{malStr[[i]], femStr[[j]]}, {i, 1, 8}, {j, 1, 8}]

Now, I want to replace elements of comStr with a series of transformation rules, such as:

Do[
If[comStr[[i, j]][[2]][[2]] == "A" &&
comStr[[i, j]][[1]][[1]] == "M",
Print[comStr[[i, j]] /. "A" -> "H"],
Print[comStr[[i, j]] /. "A" -> "L"]], {i, 1, 8}, {j, 1, 8}]

This does the replacement, and prints out the output; however, what I need is to generate a new table with the values replaced.

Can anybody suggest how to do this? Any suggestions on how to improve the above also welcome --- the transformation rules can get a little complicated.

Many thanks,
Laura

URL: ,

Subject (listing for 'applying transformation rules to table')
Author Date Posted
applying transformation rules to table Laura 08/23/10 10:47am
Re: applying transformation rules to table Peter Pein 08/23/10 8:00pm
Re: Re: applying transformation rules to table Laura 08/24/10 11:44am
Re: Re: Re: applying transformation rules to ta... Peter Pein 08/27/10 03:01am
Next Comment >Help | Reply To Topic