explain the effect of the cut (!) predicates in PROLOG?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • no comment
    New Member
    • May 2010
    • 1

    explain the effect of the cut (!) predicates in PROLOG?

    explain the effect of the cut (!) predicates in PROLOG?
  • franknagy
    New Member
    • Oct 2011
    • 27

    #2
    Usage of cut after repeat-fail constructs

    The cut opeator (denoted by !) stops the backtracking back to it.

    Code:
    repeat,
      possible_values(X),
      do_something(X,Y),
      check(X),
    !,
    continue_task(Y),
    The cut in the above fragment prevents the backtracking to
    Code:
    do_something(X,Y)
    in case of failed
    Code:
    continue_task(Y)
    .

    _____________
    Hint
    Code:
    PREDICATES
      nondeterm repeat
    CLAUSES
      repeat.
      repeat if repeat.
    Regards
    Frank

    Comment

    Working...