I have to solve a problem with a unique definition of the natural numbers:
(define-type Nat (U 'Zero Succ))
(define-struct Succ ([prev : Nat]) #:transparent)
So basically, 0 = 'Zero, 1 = (Succ 'Zero), 2 = (Succ (Succ 'Zero)).... etc.
Using this form, without converting them into integers, I have write recursive functions to add, subtract, and multiply the natural numbers. For the add function I've tried this
(: nat+ : Nat Nat -> Nat)
(define (nat+ n m)
(match '(n m)
['('Zero 'Zero) 'Zero]
['((Succ p) 'Zero)
n]
['('Zero (Succ p))
m]
['((Succ p) (Succ t))
(nat+ p (Succ m))]))
but I get the error
p: unbound identifier in module in: p.
Does anyone have any advice for writing this type of recursive function.