Here is pseudo for Cartesian mapping.
A -> Pair<A,"letter"> -> C
B -> Pair<B,"number"> -> D
Merge(C,D) -> lift(new CartesianOperator) -> Result
The Cartesian operator would store a list of numbers, and a list of characters.
In the event that a unique character is introduced. You generate responses for every combination of the unique character with your list of recorded numbers. Then you add your unique character to the charter-list, then repeat the process.
You do the same for unique numbers.
In the end you'll be able to send Something like 1,1,2,3 and a,b,b, and receive something like (a,1)(a,2)(a,3)(b,1)(b,2)(b,3)
Edit:
So here is a quick, and admittedly un-scalable, implementation that would work. It takes a pair object.
Where Value 1 is your 'a', 'b', '1', '2', or '3', and
Value 2 is your type'('number' or 'character')
It returns and observable pair of characters mapped to numbers.
public class CartesianOperator implements Observable.Operator<Pair<String,String>,Pair<String,String>> {
@Override
public Subscriber<? super Pair<String, String>> call(final Subscriber<? super Pair<String, String>> subscriber) {
return new Subscriber<Pair<String, String>>() {
List<String> numbers;
List<String> characters;
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onNext(Pair<String, String> stringStringPair) {
if(stringStringPair.second == "number")
{
if(numbers.size() == 0)
{
numbers.add(stringStringPair.first);
}
else
{
if(numbers.contains(stringStringPair.first))
{}
else
{
for(String temp: characters)
{
//Return Every permutation of existing characters with new number
subscriber.onNext( new Pair<String,String>(temp,stringStringPair.first));
}
}
}
}
else // Assume vallue is a character
{
if(characters.size() == 0)
{
characters.add(stringStringPair.first);
}
else
{
if(characters.contains(stringStringPair.first))
{}
else
{
for(String temp: numbers)
{
//Return Every permutation of existing numbers with new character
subscriber.onNext( new Pair<String,String>(stringStringPair.first,temp));
}
}
}
}
}
};
}
}
If you have no idea what a pair object is, Its essentially an object that encapsulates two other objects.
pairObject.first
Returns the first object of my pair
pairObject.second
Returns the second object of my pair
I think its deprecated by now.