public EvaluationResult evaluate(List inputs, EvaluationCtx context) {

        // Evaluate the arguments
        AttributeValue [] argValues = new AttributeValue[inputs.size()];
        EvaluationResult evalResult = evalArgs(inputs, context, argValues);
        if (evalResult != null)
            return evalResult;

        // setup the two bags we'll be using
        BagAttribute [] bags = new BagAttribute[2];
        bags[0] = (BagAttribute)(argValues[0]);
        bags[1] = (BagAttribute)(argValues[1]);

        AttributeValue result = null;
        Set set = new HashSet();
        
        switch(getFunctionId()) {

            // *-intersection takes two bags of the same type and returns
            // a bag of that type
        case ID_BASE_INTERSECTION:
            // create a bag with the common elements of both inputs, removing
            // all duplicate values

            Iterator it = bags[0].iterator();

            // find all the things in bags[0] that are also in bags[1]
            while (it.hasNext()) {
                AttributeValue value = (AttributeValue)(it.next());
                if (bags[1].contains(value)) {
                    // sets won't allow duplicates, so this addition is ok
                    set.add(value);
                }
            }

            result = new BagAttribute(bags[0].getType(), set);

            break;

            // *-union takes two bags of the same type and returns a bag of
            // that type
        case ID_BASE_UNION:
            // create a bag with all the elements from both inputs, removing
            // all duplicate values

            Iterator it0 = bags[0].iterator();
            while (it0.hasNext()) {
                // first off, add all elements from the first bag...the set
                // will ignore all duplicates
                set.add(it0.next());
            }
            
            Iterator it1 = bags[1].iterator();
            while (it1.hasNext()) {
                // now add all the elements from the second bag...again, all
                // duplicates will be ignored by the set
                set.add(it1.next());
            }

            result = new BagAttribute(bags[0].getType(), set);

            break;
        }
        
        return new EvaluationResult(result);
    }