Euler problem 22.1

(ql:quickload "str")

(defun score (word)
  (loop :for char :across word
        sum (+ (- (char-code (char-upcase char))
                  (char-code #\A))
               1)))

(defun remove-quote (name)
  (remove #\" name))

(defmacro zipWith (f xs ys)
  `(mapcar ,f ,xs ,ys))

(defmacro range (max &key (min 0) (step 1))
  `(loop :for n :from ,min :below ,max :by ,step
        collect n))

(defun name-scores (filename)
  (with-open-file (stream filename)
    (let* ((names (read-line stream))
           (name-list-q (str:split #\, names))
           (name-list (mapcar #'remove-quote name-list-q))
           (sorted-name-list (sort name-list #'string<))
           (score-list (mapcar #'score sorted-name-list))
           (n-list (range (1+ (length score-list)) :min 1))
           (i-score-list (zipWith #'* n-list score-list)))
      (reduce #'+ i-score-list))))

(name-scores "names.txt")

; SLIME 2.28To load "str":
  Load 1 ASDF system:
    str
; Loading "str"
...

CL-USER> (name-scores "names.txt")
871198282
CL-USER> 

— Me@2024-09-04 10:43:19 AM

.

.

2024.09.04 Wednesday (c) All rights reserved by ACHK