/*
 * calculate
 * Calculates an parsed expression using one stack for the operations and
 * two stack for the operands and operators.
 *
 * @param **OpStack      - The stack of operations.
 * @param **OperandStack - The stack of operands.
 */
double calculate(Stack **OpStack, Stack **OperandStack) {
    double result = 0;
    
    Stack *current = *OpStack;
    for (; current; current = current->next) {
        switch (current->opType) {
            case binaryOperation:
                //Result is always the result of the lastest made operation
                result = current->BinaryOperation(pop(OperandStack), pop(OperandStack));
                printf("Current result: %f\n", result);
                //Pushes the latest result to the operand stack incase it should be used again.
                pushOperand(OperandStack, operand, result);
                break;
                
            default:
                printf("Something else than an operation was found here..\n");
                break;
        }
    }
    
    return result;
}
/**
 * display loops through the entire Stacks linked list priting out every
 * data property found while looping through the entire list of linked Stacks.
 *
 * @param *head - The target Stack to loop through its linked elements.
 */
void display(Stack *head) {
    Stack *current = head;
    
    while (current != NULL) {
        if (current->opType == operand) {
            printf("Stack Data: %f, Stack Size: %i\n", current->operand, current->size);
        } else if (current->opType == binaryOperation) {
            printf("Stack BinaryOperationResult: %c  %f, Stack Size: %i\n", current->symbol, current->BinaryOperation(10, 10), current->size);
        }
        current = current->next;
    }
}