The version with the count
feature of loop
in Common Lisp:
(defun count-up-down-characters-with-difference (input-string up-char down-char)
"Given a string of any length, iterate each character of the string looking
for up- and down-characters
provided by the caller, and return the number of
each, as well as the difference between them."
(loop for c across input-string
count (char-equal c up-char) into count-up
count (char-equal c down-char) into count-down
finally (return (list count-up
(- count-down)
(- count-up count-down)))))