[ ECLiPSe Control built-in.|Group Index| Full 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 ingnored (cut).

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

Fail Conditions

Fails if Goal fails.

Resatisfiable

No.

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, call / 2