This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun split-sentence-to-words (sentence) | |
(let ((word '())) | |
(loop for ch across sentence | |
if (member ch '(#\space #\tab #\,)) | |
collect (coerce (reverse word) 'string) into words and do (setf word '()) | |
else | |
do (push ch word) | |
finally (return (append words (coerce (reverse word) 'string)))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun load-env (pathname) | |
(with-open-file (stream pathname) | |
(read-env stream))) | |
(defun read-env (stream) | |
(remove-nils | |
(loop for line = (read-line stream nil :eof) | |
until (eq line :eof) | |
collect (process-env-string line)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun number-to-digit-list (number) | |
(if (> number 9) | |
(append (number-to-digit-list (truncate (/ number 10))) (cons (mod number 10) '())) | |
(list number))) | |
(defun digit-list-to-number (digit-list) | |
(reduce #'+ (loop for pos from 0 | |
and digit in (reverse digit-list) | |
collect (* digit (expt 10 pos))))) |