I am trying to create a module function in haskell using primitive recursive functions . I know this is possible (because it is on the list of function examples on wikipedia)
And I know how I logically do this. But I just canβt realize it!
IE, logic (not primitive recursion or haskell)
function mod(a, b){ while(a > b) a -= b return a; }
What can I determine with recursion (again not haskel)
function mod(a, b){ if(a < b) return a; return mod(a - b, b); }
But I just can't implement it with primitive recursive functions. I beat what I canβt do, this is the logic <b
I think that to solve my problem I need some kind of specific logic, such as (again not haskel)
reduce(a, b) = a >= b -> ab otherwise x
If anyone could help me with any part of this, I would really appreciate it, thanks
Edit :: I was thinking about the potential definition of a module function using division, i.e. Mod (a, b) = a - (a / b) * b, but since my primitive recursive division function relies on modulo, I cannot do this haha