A.53 library(terms): Term manipulation
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • The SWI-Prolog library
        • library(terms): Term manipulation
          • term_size/2
          • variant/2
          • subsumes_chk/2
          • subsumes/2
          • term_subsumer/3
          • term_factorized/3
          • mapargs/3
          • mapsubterms/3
          • mapsubterms_var/3
          • foldsubterms/4
          • foldsubterms/5
          • same_functor/2
          • same_functor/3
          • same_functor/4
    • Packages
Availability::- use_module(library(terms)).(can be autoloaded)
Source[det]term_size(@Term, -Size)
True if Size is the size in cells occupied by Term on the global (term) stack. A cell is 4 bytes on 32-bit machines and 8 bytes on 64-bit machines. The calculation does take sharing into account. For example:
?- A = a(1,2,3), term_size(A,S).
S = 4.
?- A = a(1,2,3), term_size(a(A,A),S).
S = 7.
?- term_size(a(a(1,2,3), a(1,2,3)), S).
S = 11.

Note that small objects such as atoms and small integers have a size 0. Space is allocated for floats, large integers, strings and compound terms.