• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Hons-and-memoization
      • Events
      • History
      • Parallelism
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
          • Defstobj
          • Defabsstobj
          • Stobj-table
          • Preservation-thms
          • Nested-stobjs
          • Defrstobj
          • User-stobjs-modified-warnings
          • With-global-stobj
          • Stobj-example-1
          • Defrstobj
          • Stobj-example-3
          • Stobj-example-1-proofs
          • With-local-stobj
          • Stobj-example-1-defuns
          • Declare-stobjs
          • Trans-eval-and-stobjs
          • With-local-state
          • Stobj-example-2
          • Stobj-example-1-implementation
          • Swap-stobjs
          • Resize-list
            • Std/lists/resize-list
          • Nth-aliases-table
          • Trans-eval-and-locally-bound-stobjs
          • Std/stobjs
          • Count-keys
          • Update-nth-array
        • State
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
        • Mutual-recursion
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
        • Time$
        • Loop$-primer
        • Fast-alists
        • Defmacro
        • Defconst
        • Evaluation
        • Guard
        • Equality-variants
        • Compilation
        • Hons
        • ACL2-built-ins
        • Developers-guide
        • System-attachments
        • Advanced-features
        • Set-check-invariant-risk
        • Numbers
        • Irrelevant-formals
        • Efficiency
        • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
        • Redefining-programs
        • Lists
        • Invariant-risk
        • Errors
        • Defabbrev
        • Conses
        • Alists
        • Set-register-invariant-risk
        • Strings
        • Program-wrapper
        • Get-internal-time
        • Basics
        • Packages
        • Defmacro-untouchable
        • Primitive
        • <<
        • Revert-world
        • Set-duplicate-keys-action
        • Unmemoize
        • Symbols
        • Def-list-constructor
        • Easy-simplify-term
        • Defiteration
        • Defopen
        • Sleep
      • Start-here
      • Real
      • Debugging
      • Miscellaneous
      • Output-controls
      • Macros
      • Interfacing-tools
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Testing-utilities
    • Math
  • Stobj
  • ACL2-built-ins

Resize-list

List resizer in support of stobjs

(Resize-list lst n default-value) takes a list, lst, and a desired length, n, for the result list, as well as a default-value to use for the extra elements if n is greater than the length of lst.

Resize-list has a guard of t. This function is called in the body of function, resize-<a> where <a> is an array field of a stobj. See defstobj.

Function: resize-list-exec

(defun
 resize-list-exec
 (lst n default-value acc)
 (declare (xargs :guard (true-listp acc)))
 (if (and (integerp n) (> n 0))
     (resize-list-exec (if (atom lst) lst (cdr lst))
                       (1- n)
                       default-value
                       (cons (if (atom lst) default-value (car lst))
                             acc))
     (reverse acc)))

Function: resize-list

(defun
    resize-list (lst n default-value)
    (declare (xargs :guard t))
    (mbe :logic (if (and (integerp n) (> n 0))
                    (cons (if (atom lst) default-value (car lst))
                          (resize-list (if (atom lst) lst (cdr lst))
                                       (1- n)
                                       default-value))
                    nil)
         :exec (resize-list-exec lst n default-value nil)))

Subtopics

Std/lists/resize-list
Lemmas about resize-list available in the std/lists library.