rules={{"A2", "BO"}, {"A2", "BO"}, {"A2", "BO"}, {"A2", "BO"}, {"A2", 
"BO"}, {"A2", "BO"}, {"A2", "BO"}, {"A2", "BO"}, {"A2", 
"BO"}, {"A2", "BO"}, {"A2", "BO"}, {"A2", "BO"}, {"A2", 
"BO"}, {"A2", "BO"}, {"A2", "BO"}, {"A2", "BO"}, {"A2", 
"BO"}, {"A2", "BX"}, {"A2", "BO"}, {"A2", "BO"}, {"A2", 
"BX"}, {"A2", "BE"}, {"A2", "BO"}, {"A2", "BO"}, {"A2", 
"BO"}, {"A2", "BO"}, {"A2", "BX"}, {"A2", "BX"}, {"A2", 
"BE"}, {"A2", "BO"}, {"A2", "BO"}, {"A2", "BO"}, {"A2", 
"BX"}, {"A2", "BO"}, {"A2", "BO"}, {"A2", "BX"}, {"A2", 
"BO"}, {"A1", "BL"}, {"A1", "BL"}, {"A1", "BL"}, {"A1", 
"BL"}, {"A1", "BL"}, {"A1", "BL"}, {"A1", "BP"}, {"A1", 
"BP"}, {"A1", "BL"}, {"A1", "BP"}, {"A1", "BL"}, {"A1", 
"BP"}, {"A1", "BP"}, {"A1", "BP"}, {"A1", "BP"}, {"A1", 
"BP"}, {"A1", "BL"}, {"A1", "BP"}, {"A1", "BL"}, {"A1", 
"BL"}, {"A1", "BL"}, {"A1", "BP"}, {"A1", "BL"}, {"A1", 
"BP"}, {"A1", "BP"}, {"A1", "BL"}, {"A1", "BE"}, {"A1", 
"BL"}, {"A1", "BL"}, {"A1", "BP"}, {"A1", "BL"}, {"A1", 
"BE"}, {"F2", "BO"}, {"F2", "BL"}, {"F2", "BP"}, {"F1", 
"BL"}, {"F1", "BP"}, {"F1", "BL"}, {"F1", "BP"}, {"F2", 
"BL"}, {"F2", "BL"}, {"F2", "BO"}, {"F2", "BO"}, {"F2", 
"BO"}, {"F2", "BO"}, {"F1", "BL"}, {"F1", "BL"}, {"F1", 
"BL"}, {"F1", "BL"}, {"F1", "BP"}, {"F1", "BP"}, {"F1", 
"BL"}, {"F1", "BL"}, {"F1", "BL"}, {"F1", "BO"}};

I have a list that represented as follows. A1,A2,F1 are the locations of compartments, BO,BE,BL... are the descriptions of the items within A1,A2,A3.

I would like to visualize the placement of the items within each compartment to test for the lack of sortation. I was thinking of a LayeredGraphPlot but my list needs work. How would I make a function to convert my list to look like this.

{"A2" -> "BO1", "A2" -> "BO2", "A2" -> "BO3", "A2" -> "BO4", 

"A2" -> "BO5".....} The order can not be changes and each item numbered (i.e. BO1,BO2...BOn),the numbering of each item is the total of the individual item.

Thanks Bob

  • $\begingroup$ try using Apply, for instance Apply[Rule, rules, {1}] $\endgroup$ – bobknight Jul 5 '15 at 17:35
  • $\begingroup$ Bob, I see that you have been on-line recently but you did not comment on my answer. Is the output as you desire? $\endgroup$ – Mr.Wizard Jul 5 '15 at 22:45
  • $\begingroup$ @Mr.Wizard I think the answer is perfect! I should've thought of that. And I'm trying to get used to the app for this forum. Thank you! $\endgroup$ – Bob Brooks Jul 5 '15 at 22:50
  • $\begingroup$ You're welcome, and I am glad I could help. I did not mean to rush you to Accept my answer. (Personally I wait 24 hours before accepting an answer to give everyone a chance to answer first.) I just wondered if I had misunderstood. I imagine you'll find more uses for that simple count method; I know I do. $\endgroup$ – Mr.Wizard Jul 5 '15 at 23:05
  • $\begingroup$ @Mr.Wizard One look at your answer, and I knew it was the correct one, thanks again. And I'm still trying to get used to this new app I got today.One more question, would this be a neat and tidy way to visualize my so-called sortation? Or is there an alternative that might be better. $\endgroup$ – Bob Brooks Jul 5 '15 at 23:43

I believe you want this:

 count[__] = 0;
 # -> #2 <> ToString[++count[##]] & @@@ rules
{"A2" -> "BO1", "A2" -> "BO2", "A2" -> "BO3", "A2" -> "BO4", "A2" -> "BO5", "A2" -> "BO6",
  "A2" -> "BO7", "A2" -> "BO8", "A2" -> "BO9", "A2" -> "BO10", "A2" -> "BO11", 
 "A2" -> "BO12", "A2" -> "BO13", "A2" -> "BO14", "A2" -> "BO15", "A2" -> "BO16", 
 "A2" -> "BO17", "A2" -> "BX1", "A2" -> "BO18", "A2" -> "BO19", "A2" -> "BX2", 
 "A2" -> "BE1", "A2" -> "BO20", "A2" -> "BO21", "A2" -> "BO22", "A2" -> "BO23", 
 "A2" -> "BX3", "A2" -> "BX4", "A2" -> "BE2", "A2" -> "BO24", "A2" -> "BO25", 
 "A2" -> "BO26", "A2" -> "BX5", "A2" -> "BO27", "A2" -> "BO28", "A2" -> "BX6", 
 "A2" -> "BO29", "A1" -> "BL1", "A1" -> "BL2", "A1" -> "BL3", "A1" -> "BL4", 
 "A1" -> "BL5", "A1" -> "BL6", "A1" -> "BP1", "A1" -> "BP2", "A1" -> "BL7", "A1" -> "BP3",
  "A1" -> "BL8", "A1" -> "BP4", "A1" -> "BP5", "A1" -> "BP6", "A1" -> "BP7", 
 "A1" -> "BP8", "A1" -> "BL9", "A1" -> "BP9", "A1" -> "BL10", "A1" -> "BL11", 
 "A1" -> "BL12", "A1" -> "BP10", "A1" -> "BL13", "A1" -> "BP11", "A1" -> "BP12", 
 "A1" -> "BL14", "A1" -> "BE1", "A1" -> "BL15", "A1" -> "BL16", "A1" -> "BP13", 
 "A1" -> "BL17", "A1" -> "BE2", "F2" -> "BO1", "F2" -> "BL1", "F2" -> "BP1", 
 "F1" -> "BL1", "F1" -> "BP1", "F1" -> "BL2", "F1" -> "BP2", "F2" -> "BL2", "F2" -> "BL3",
  "F2" -> "BO2", "F2" -> "BO3", "F2" -> "BO4", "F2" -> "BO5", "F1" -> "BL3", 
 "F1" -> "BL4", "F1" -> "BL5", "F1" -> "BL6", "F1" -> "BP3", "F1" -> "BP4", "F1" -> "BL7",
  "F1" -> "BL8", "F1" -> "BL9", "F1" -> "BO1"}

Recommended reading:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.