Skip to content

Instantly share code, notes, and snippets.

@joelmccracken
Last active August 29, 2015 13:56
Show Gist options
  • Save joelmccracken/9244958 to your computer and use it in GitHub Desktop.
Save joelmccracken/9244958 to your computer and use it in GitHub Desktop.
add(0, Y, Y).
add(succ(X), Y, succ(Z)) :- add(X,Y,Z).
mult(0,_,0).
mult(succ(0), Z, Z).
mult(succ(X),Y,Z) :- add(ZZ, Y, Z), mult(X, Y, ZZ).
@joelmccracken
Copy link
Author

?- tspy(mult).
% Spy point on mult/3
ERROR: '$c_call_prolog'/0: Undefined procedure: thread_util:gdebug/0
ERROR: However, there are definitions for:
ERROR: thread_util:tdebug/0
ERROR: thread_util:tdebug/1

@joelmccracken
Copy link
Author

add(0, Y, Y).
add(Y, 0, Y).
add(succ(X), Y, succ(Z)) :- add(X,Y,Z).

mult(0,_,0).
mult(succ(0), Z, Z).
mult(succ(X),Y,Z) :- add(ZZ, Y, Z), mult(X, Y, ZZ).

@Anniepoo
Copy link

add(0, Y, Y).
add(Y, 0, Y).
add(succ(X), Y, succ(Z)) :- add(X,Y,Z).

mult(0,_,0).
mult(succ(0), Z, Z).
mult(succ(X),Y,Z) :- add(ZZ, Y, Z), mult(X, Y, ZZ).

1 ?- edit.
true.

2 ?- mult(succ(succ(0)), succ(succ(0)), Z).
Z = succ(succ(succ(succ(0)))) .

3 ?-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment