[ Control | Reference Manual | Alphabetic Index ]

once +Goal

Succeeds if Goal succeeds, and removes all its alternatives --- equivalent to call((Goal, !))
Goal
Goal.

Description

Used to find a single solution for Goal, alternative solutions are ignored (cut).

Note that !/0 does not cut through once/1.

Modes and Determinism

Modules

This predicate is sensitive to its module context (tool predicate, see @/2).

Fail Conditions

Fails if Goal fails

Exceptions

(4) instantiation fault
Goal is not instantiated.
(5) type error
Goal is neither an atom nor a compound term.

Examples

Success:
      [eclipse]: once member(X, [1,2,3]).
      X = 1       % only first solution is bound.
      yes.

Fail:
      [eclipse]: once 1=2.
      no.

Error:
      once Goal.                     (Error 4).
      once "ls".                     (Error 5).
      once 1.0.                      (Error 5).



See Also

call / 1, -> / 2