Skip to content

when SHOULD you use the cut (!/0)? #2501

Closed Answered by triska
jjtolton asked this question in Q&A
Discussion options

You must be logged in to vote

Every known computation can be expressed in Prolog without !/0. One can show this by implementing a Turing machine in that subset of Prolog, which I have done with:

https://www.metalevel.at/prolog/showcases/turing.pl

Thus, I find it hard to think of even a hypothetical case where one could justifiably say: "you SHOULD use !/0". With every known computation being expressible without using !/0, where would such a justification come from? It seems far more likely that it can be expressed not only in one (which is certain to exist), but even in several different additional ways without using !/0.

One note about Prolog terminology: !/0 is not an operator:

?- current_op(Pri, Fix, !).
   false.

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
6 replies
@jjtolton
Comment options

@hurufu
Comment options

@UWN
Comment options

@jjtolton
Comment options

@jjtolton
Comment options

Answer selected by jjtolton
Comment options

You must be logged in to vote
3 replies
@hurufu
Comment options

@triska
Comment options

@hurufu
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants