• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
      • Io
      • Defttag
      • Sys-call
      • Save-exec
      • Quicklisp
      • Std/io
      • Oslib
      • Bridge
      • Clex
        • Example-lexer
        • Sin
          • Strin-p
          • Sin$c
            • Line-and-column-tracking
              • Lc-nthcdr-str
              • Line-after-nthcdr
              • Col-after-nthcdr
              • Lc-nthcdr
                • Lc-nthcdr-str-fast
              • Sin$c-okp
              • Sin$c-init
              • Sin$c-nthcdr
              • Sin$c-cdr
              • Sin$c-firstn
              • Sin$c-count-charset
              • Sin$c-nth
              • Sin$c-matches-p
              • Sin$c-imatches-p
              • Sin$c-find
              • Sin$c-len
              • Sin$c-endp
              • Sin$c-car
              • Sin$corr
              • Sin$c-get-line
              • Sin$c-get-file
              • Sin$c-get-col
          • Matching-functions
          • Def-sin-progress
        • Tshell
        • Unsound-eval
        • Hacker
        • ACL2s-interface
        • Startup-banner
        • Command-line
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Line-and-column-tracking

    Lc-nthcdr

    Like nthcdr into a character list, but simultaneously computes the new line and column numbers.

    Signature
    (lc-nthcdr n x line col) → (mv new-chars new-line new-col)
    Arguments
    n — How many characters to advance.
        Guard (natp n).
    x — Characters we're processing.
        Guard (character-listp x).
    line — Current line number.
        Guard (natp line).
    col — Current column number.
        Guard (natp col).
    Returns
    new-chars — Remaining characters after advancing.
    new-line — Line number after advancing.
    new-col — Column number after advancing.

    Definitions and Theorems

    Function: lc-nthcdr

    (defun lc-nthcdr (n x line col)
      (declare (xargs :guard (and (natp n)
                                  (character-listp x)
                                  (natp line)
                                  (natp col))))
      (declare (type (integer 0 *) n line col))
      (let ((__function__ 'lc-nthcdr))
        (declare (ignorable __function__))
        (mbe :logic
             (mv (nthcdr n x)
                 (line-after-nthcdr n x line)
                 (col-after-nthcdr n x col))
             :exec
             (b* (((when (or (zp n) (atom x)))
                   (mv x line col))
                  ((the character char1) (car x))
                  ((the (integer 0 *) n) (- (lnfix n) 1)))
               (if (eql char1 #\Newline)
                   (lc-nthcdr n (cdr x) (+ 1 line) 0)
                 (lc-nthcdr n (cdr x)
                            line (+ 1 col)))))))