#include "calculator.h"

int add(int a, int b){ return a + b;}
int sub(int a, int b){ return a - b;}
int mul(int a, int b){return a * b;}
int div(int a, int b){return a / b;}
int mod(int a, int b){return a % b;}


int calculator(int a, int b, enum operation op)
{
    const operator lookup_table_name[] = {

        [ADD] = &add,
        [SUB] = &sub,
        [MUL] = &mul,
        [DIV] = &div,
        [MOD] = &mod,
    };

    return lookup_table_name[op](a, b);
}
/*
#include <stdio.h>
int main(void)
{
    int a = 144;
    int b = 10;
    enum operation op = MOD;
    printf("calculator(%d, %d, %d) = %d\n", a, b, op, calculator(a, b, op));
}
*/
