Natural number in SWI-prolog & recursive procedure

前端 未结 1 2131
天涯浪人
天涯浪人 2021-01-07 03:04

I have the next procedure for natural number is SWI-prolog:

natural_number(0).
natural_number(s(X)) :- natural_number(X).

Now I want to do

相关标签:
1条回答
  • 2021-01-07 03:39
    natural_number(s(0), 0).
    natural_number(s(s(X)), N) :- natural_number(s(X), S), N is S + 1.
    
    0 讨论(0)
提交回复
热议问题