Commit ee59a686 authored by Antoine Martin's avatar Antoine Martin
Browse files

Add function to build index from directory listing

parent 6db76b52
......@@ -5,7 +5,8 @@
(:export :print-primary-systems
(in-package :quickref)
......@@ -69,3 +70,24 @@
(defun get-directory-list (path)
(loop for dir in (directory path)
collect (car (last (pathname-directory dir)))))
(defun get-first-letter (sequence)
(subseq sequence 0 1))
(defun build-index (path file-path)
(with-open-file (file file-path
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
(let* ((dir-list (get-directory-list path))
(first-letter (get-first-letter (first dir-list)))
(length 0))
(loop repeat (list-length dir-list)
for pos = dir-list then (cdr pos)
do (if (string= first-letter (get-first-letter (car pos)))
(setq length (+ length 1))
(print-columns dir-list length file)
(setq length 0)
(setq dir-list pos)
(setq first-letter (get-first-letter (car pos)))))))))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment