How to catch exception to backtrack(or Delimited Continuations) in Prolog?
问题 I'm new to Prolog and trying to know some example for catch/3. The code I want to run is here. (Using swi-prolog v8.0.3) mylib.pl mylib([1,2]). mylib(1). test(X):- mylib(X), length([1],X). then consult it in swipl then run the following command. catch(test(X),error(Err,_Context),format('catch')). So here I want to catch the typeError exception and get X = 1 . But the result is catching the exception and nothing continues. So what should I do to reach my target? Running messages here. catch