Skip to content
  • A different parse can be used in a different version of this function (or it could be turned into a higher order function).

    For example, the collect body could be this if the input is only integers:

    :collect (parse-integer string :start start :end (or end (length string)))
  • The higher order function version could use this as its collect:

    :collect (funcall function string :start start :end (or end (length string)))

    That would only require changing the function signature to:

    (defun parse-and-split-string (string function &optional debug)

    Then it could be called like this:

    (parse-and-split-string "123 23487 39"
                            (lambda (string &key start end)
                              (read-from-string string t nil :start start :end end)))
  • Finally, using the higher order function version, we have just reinvented a subset of yet another split-sequence if we have a "plain" parse function. That function is subseq:

    (parse-and-split-string "123 456 789"
                            (lambda (seq &key start end)
                              (subseq seq start end)))
    ;; => ("123" "456" "789")
    Edited by Michael Babich
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment