#!/usr/local/bin/clisp -ansi -q -norc -Kfull ;; -*- mode: common-lisp -*- ;; Replaces any sequences of non alphanumeric or dot character in the ;; arguments by a single dash. (defun split-string-if (predicate string &key remove-empty-subseqs) " NOTE: current implementation only accepts as separators a string containing literal characters. " (let ((chunks '()) (position 0) (nextpos 0) (strlen (length string))) (loop :while (< position strlen) :do (loop :while (and (< nextpos strlen) (not (funcall predicate (aref string nextpos)))) :do (incf nextpos)) (push (subseq string position nextpos) chunks) (setf position (1+ nextpos) nextpos position)) (nreverse chunks))) (defun clean-name (name) (format nil "~{~A~^-~}" (split-string-if (lambda (char) (not (or (alphanumericp char) (char= char #\/) (char= char #\.)))) (string-downcase name) :remove-empty-subseqs t))) (defun main (argv) (dolist (arg argv) (princ (clean-name arg)) (terpri))) (main ext:*args*)