At Uni we were given a challenge of creating a tail recursive addition of Peano numbers using an accumulator. We aren't allowed to use any library function or other functions that we have created, but we are allowed to 'hide' the accumulator in an auxiliary function
Here's the type
type Peano =
| O
| S of Peano
I'm stuck at how to execute the accumulator as it has no operation on the type defined, i.e. the following is not possible
let tailAdd p1 p2 =
let rec aux p1 p2 acc =
match p1, p2 with
| O, _ -> acc
| S v, b -> aux v b (acc + v)
aux p1 p2 O
Help xD