Skip to content

Instantly share code, notes, and snippets.

@emdeesee
Last active March 21, 2020 22:54
Show Gist options
  • Save emdeesee/f8c79e3b87bd4519355eb555dde2e4c0 to your computer and use it in GitHub Desktop.
Save emdeesee/f8c79e3b87bd4519355eb555dde2e4c0 to your computer and use it in GitHub Desktop.
utilities for scraping/parsing
(ql:quickload :str)
(ql:quickload :alexandria)
(import 'alexandria:compose)
(ql:quickload :arrows)
(use-package :arrows)
(defun split-names (s)
(mapcar (compose #'str:downcase #'str:trim) (str:split #\, s)))
(let (names)
(defun update-names-list (list)
(setf names (append names list)))
(defun clear-names ()
(setf names nil))
(defun get-names ()
names))
(defun parse-names (s)
(-> s
split-names
update-names-list))
(defun save-names (path list)
(with-open-file (s path :direction :output :if-does-not-exist :create :if-exists :overwrite)
(print list s)))
(defun load-names (path)
(with-open-file (s path)
(read s)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment