• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
      • Std/lists
      • Std/alists
      • Obags
      • Std/util
      • Std/strings
        • Pretty-printing
        • Printtree
        • Base64
        • Charset-p
        • Strtok!
        • Cases
        • Concatenation
          • Revappend-chars
          • Join
          • Append-chars
          • Cat
          • Rchars-to-string
          • Prefix-strings
        • Html-encoding
        • Character-kinds
        • Substrings
        • Strtok
        • Equivalences
        • Url-encoding
        • Lines
        • Explode-implode-equalities
        • Ordering
        • Numbers
        • Pad-trim
        • Coercion
        • Std/strings/digit-to-char
        • Substitution
        • Symbols
      • Std/osets
      • Std/io
      • Std/basic
      • Std/system
      • Std/typed-lists
      • Std/bitsets
      • Std/testing
      • Std/typed-alists
      • Std/stobjs
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Math
    • Testing-utilities
  • Std/strings

Concatenation

Functions for joining strings together.

Efficiency Warning. Concatenating strings in ACL2 is fundamentally slow. Why? In Common Lisp, strings are just arrays of characters, and there is not any mechanism for efficiently splicing together arrays. Any kind of string concatenation, then, minimally requires creating a completely new array and copying all of the input characters into it. This makes it especially slow to repeatedly use, e.g., cat to build up a string.

To build strings more efficiently, a good general strategy is to build up a reverse-order character list, and then convert it into a string at the end. See for instance the functions revappend-chars and rchars-to-string, which make this rather easy to do.

Subtopics

Revappend-chars
Append a string's characters onto a list, in reverse order.
Join
Concatenate a list of strings with some separator between.
Append-chars
Append a string's characters onto a list.
Cat
Alternative to concatenate that has a shorter name and may in some cases be more efficient.
Rchars-to-string
Possibly optimized way to reverse a character list and coerce it to a string.
Prefix-strings
Concatenates a prefix onto every string in a list of strings.