LL Golf Hole 4

doukaku.org
正規表現使わずに、CLとxyzzyで動くよう解いてみる。

(defun llgolf4 (f)
  (flet ((p (c) (or (alpha-char-p c) (digit-char-p c))))
    (with-open-file (s f)
      (do ((h (make-hash-table :test #'equal))
           (r 0 (1+ r))
           (l "" (read-line s nil)))
          ((not l) (maphash #'(lambda (k v) (format t "~A ~A~%" k (reverse v))) h))
        (do* ((a 0 (1+ a)) (b))
            ((>= a (length l)))
          (when (p (char l a))
            (setq b (or (position-if-not #'p l :start a) (length l)))
            (pushnew r (gethash (subseq l a b) h))
            (setq a b)))))))

なんか気持ち悪い。なんだろなコレ。
やっぱり正規表現関係のユーティリティー用意しとこう。

とりあえず実行

(llgolf4 "~/sandbox/golf/gpl.txt")
they (36 37 226 348 349 543)
authorization (311)
transferring (453)
protocols (335)
we (22 29 55 57 63)
cases (301 357)
part (84 125 140 181 320 350 355 390 558)
;--中略--
could (64 458 549)
them (25 37 51 167 172 233 516 630)
html (674)
offer (41 206 259 260 270 272 276 489)
inside (51)
semiconductor (78)
thus (170 475)
nil

kozima氏のCommonLispの回答見たけど、loopってhashも行けるのか…
覚えられる気がしない。