#3

The function add adds two quantities in the representation of #2:

add([], M) => M;       // first list is empty

add(L, []) => L;       // second list is empty

add([[A, I] | L], [[A, J] | M]) => [[A, I+J] | add(L, M)];  // same units

add([[A, I] | L], [[B, J] | M]) =>                          // different units
  A < B ? [[A, I] | add(L, [[B, J] | M])]                   // use sorted property
        : [[B, J] | add([[A, I] | L], M)];