• 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
        • State
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
        • Mutual-recursion
        • Loop$
        • Programming-with-state
        • Arrays
        • Characters
          • Character-listp
          • Characterp
          • Coerce
          • Standard-char-p
          • Digit-char-p
          • Code-char
          • Char-code
          • Char-downcase
          • Char
          • Char-upcase
          • Explode-nonnegative-integer
          • Explode-atom
            • Alpha-char-p
            • Upper-case-p
            • Lower-case-p
            • Char-equal
            • Digit-to-char
            • Char<
            • Char>=
            • Make-character-list
            • Char>
            • Char<=
            • Standard-char-listp
            • Character-alistp
            • Standard-char-p+
            • Chars-upcase-gen
            • Chars-downcase-gen
            • Char-upcase-gen
            • Char-downcase-gen
          • 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
    • Characters
    • ACL2-built-ins

    Explode-atom

    Convert any atom into a character-listp that contains its printed representation, rendering numbers in your choice of print base.

    (explode-atom x print-base) prints the atom x as a list of characters, using some print-base-p to decide what base to print numbers in.

    Examples:

    (explode-atom 15 10) --> (#\1 #\5)              ; 15 in decimal
    (explode-atom 15 16) --> (#\F)                  ; 15 in hex
    (explode-atom "foo" 10) --> (#\f #\o #\o)
    (explode-atom 'acl2::foo 10) --> (#\F #\O #\O)  ; note: no package

    See also explode-nonnegative-integer, str::numbers, and printing-to-strings.

    Function: explode-atom

    (defun
     explode-atom (x print-base)
     (declare (xargs :guard (and (or (acl2-numberp x)
                                     (characterp x)
                                     (stringp x)
                                     (symbolp x))
                                 (print-base-p print-base))))
     (cond
      ((rationalp x)
       (cond
        ((integerp x)
         (cond ((< x 0)
                (cons #\-
                      (explode-nonnegative-integer (- x)
                                                   print-base nil)))
               (t (explode-nonnegative-integer x print-base nil))))
        (t
         (append (explode-atom (numerator x) print-base)
                 (cons #\/
                       (explode-nonnegative-integer (denominator x)
                                                    print-base nil))))))
      ((complex-rationalp x)
       (list*
            #\# #\C #\(
            (append (explode-atom (realpart x) print-base)
                    (cons #\Space
                          (append (explode-atom (imagpart x) print-base)
                                  '(#\)))))))
      ((characterp x) (list x))
      ((stringp x) (coerce x 'list))
      (t (coerce (symbol-name x) 'list))))