4.33 Global variables
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Global variables
          • b_setval/2
          • b_getval/2
          • nb_setval/2
          • nb_getval/2
          • nb_linkval/2
          • nb_current/2
          • nb_delete/1
          • Compatibility of SWI-Prolog Global Variables
    • Packages
Availability:built-in
nb_setval(+Name, +Value)
Associates a copy of Value created with duplicate_term/2 with the atom Name. Note that this can be used to set an initial value other than [] prior to backtrackable assignment. Starting with version 9.3.18, if the new Value contains the old value, the old value is not copied. This implies that push/1 below has complexity O(1), regardless of the length of the list Old.
push(Var, Value) :-
    nb_getval(Var, Old),
    nb_setval(Var, [Value|Old]).