I hope I can state this fact here and now and give a full solution later. To illustrate my point (B) above, try:
\makeatletter
\newcount\cnta
\cnta\z@
\foreach \p/\q in {A,B}{%
\global\advance\cnta\@ne
\expandafter\xdef\csname result@\romannumeral\cnta\endcsname{\q}%
}
\edef\result{\result@i,\result@ii}
\show\result
\makeatother
A general scheme like the following will be preferred, but I guess there is already a package that offers this DB functionality.
\def\collections{
1/colors: 1/red, 2/green, 3/blue;
2/tech makers: 1/Toyota, 2/Apple, 3/Samsung, 4/Motorola, 5/Honda;
3/IT firms: 1/Apple, 2/Microsoft, 3/Google, 4/Oracle;
4/automakers: 1/Toyota, 2/Ford, 3/Mercedes, 4/GM, 5/Honda;
5/units: 1/pt, 2/ex, 3/em, 4/cc, 5/in;
6/sports: 1/basketball, 2/tennis, 3/football, 4/soccer;
7/energy: 1/gas, 2/oil, 3/coal, 4/solar, 5/nuclear;
}
% Eg, \addrow{Continents: Africa, Asia, Europe, N.America, S.America, Ausie?}
\def\addrow#1{%
}
% Eg, \removerow{IT firms}
\def\removerow#1{%
}
% Eg, \addcol{units}{mm}
\def\addcol#1#2{%
}
% Eg, \removecol{sports}{tennis}
\def\removecol#1#2{%
}
% 1. What is the association (row) of automakers?
% 2. What is the association (column) of GM in automakers?
% Eg, \rowof{automakers}
\def\rowof#1{%
}
% Eg, \rowandcolof{automakers}{GM}
\def\rowandcolof#1#2{%
}
\ifassoc{42}{|_|42|_|/ab|_|,|_|43/cd|_|}, but fails for, eg,\ifassoc{ab}{|_|ab|_|/42|_|,|_|cd/43|_|}, where|_|is space. The difference is in the way xstring does comparisons for numbers and plain strings. Spurious spaces may easily get into the list. Hence a robust solution should first trim the spurious spaces. Also, either slash (/) or comma (,) may uncommonly be active, making the list unparsable with\foreach. (B) If you do\foreach \a/\b in {42,3.14}{<do>},\bwill be42and3.14for the 2 items. – Ahmed Musa Sep 05 '12 at 17:25