public void apply(final RippleList arg,
final Sink<RippleList> solutions,
final ModelConnection mc) throws RippleException {
RippleList stack = arg;
final RippleValue mappingVal = stack.getFirst();
stack = stack.getRest();
RippleValue listVal = stack.getFirst();
final RippleList rest = stack.getRest();
// Note: it is simply assumed that these mappings have a production of
// exactly one item.
final Collector<Operator> operators = new Collector<Operator>();
Operator.createOperator(mappingVal, operators, mc);
Sink<RippleList> listSink = new Sink<RippleList>() {
public void put(final RippleList list) throws RippleException {
if (list.isNil()) {
solutions.put(rest.push(list));
}
// TODO: this is probably a little more complicated than it needs to be
else {
RippleList inverted = list.invert();
RippleValue f = inverted.getFirst();
for (Operator operator : operators) {
StackMapping inner = new InnerMapping(mc.list(), inverted.getRest(), operator);
solutions.put(rest.push(f).push(mappingVal).push(Operator.OP).push(new Operator(inner)));
}