|
|
@ -7,7 +7,7 @@
|
|
|
|
(defparameter *-utils-lisp* t)
|
|
|
|
(defparameter *-utils-lisp* t)
|
|
|
|
(defparameter *-utils-depends* '(#:cl-ppcre))
|
|
|
|
(defparameter *-utils-depends* '(#:cl-ppcre))
|
|
|
|
|
|
|
|
|
|
|
|
(defparameter *-utils-version* "0.0.2")
|
|
|
|
(defparameter *-utils-version* "0.1.2")
|
|
|
|
|
|
|
|
|
|
|
|
;;; -- Handle internal exporting --
|
|
|
|
;;; -- Handle internal exporting --
|
|
|
|
|
|
|
|
|
|
|
@ -40,7 +40,7 @@
|
|
|
|
contents)))
|
|
|
|
contents)))
|
|
|
|
(export? file-get-contents)
|
|
|
|
(export? file-get-contents)
|
|
|
|
|
|
|
|
|
|
|
|
(defun utils->system (input output &key (name :utils) (description "Some random utilities") (author "Ringo <flanchan@cumallover.me>") (license "None"))
|
|
|
|
(defun utils->system (input output &key (name :iflan-utils) (description "Some random utilities") (author "Ringo <flanchan@cumallover.me>") (license "None"))
|
|
|
|
"Write this file to an ASDF system."
|
|
|
|
"Write this file to an ASDF system."
|
|
|
|
(let ((this (cadddr (read-from-string (file-get-contents input))))
|
|
|
|
(let ((this (cadddr (read-from-string (file-get-contents input))))
|
|
|
|
(sysdef `(asdf:defsystem ,name
|
|
|
|
(sysdef `(asdf:defsystem ,name
|
|
|
@ -63,6 +63,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
;;; --- actual (exported) code goes here ---
|
|
|
|
;;; --- actual (exported) code goes here ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun true (f)
|
|
|
|
|
|
|
|
(not (null f)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun nop ()
|
|
|
|
|
|
|
|
nil)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun yep ()
|
|
|
|
|
|
|
|
t)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun mapline (input fi &key (read-line #'read-line))
|
|
|
|
|
|
|
|
"Map lines from stream"
|
|
|
|
|
|
|
|
(loop for line = (funcall read-line input nil)
|
|
|
|
|
|
|
|
while line do (funcall fi line)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro strcat (&rest str)
|
|
|
|
|
|
|
|
`(apply #'concatenate (cons 'string ,@str)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro until (stmt)
|
|
|
|
|
|
|
|
`(let ((ret nil))
|
|
|
|
|
|
|
|
(loop while (null (setf ret ,stmt)))
|
|
|
|
|
|
|
|
ret))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro until-trace (stmt)
|
|
|
|
|
|
|
|
`(let ((ret nil))
|
|
|
|
|
|
|
|
(loop while (null (setf ret ,stmt))
|
|
|
|
|
|
|
|
collect ret)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro popor (li or)
|
|
|
|
|
|
|
|
`(if (atom ,li) ,or
|
|
|
|
|
|
|
|
(pop ,li)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun rand-in (l &key (random #'random) )
|
|
|
|
|
|
|
|
"Random member of, slide right if nil"
|
|
|
|
|
|
|
|
(let ((rng (funcall random (list-length l))))
|
|
|
|
|
|
|
|
(let ((nl (nth rng l)))
|
|
|
|
|
|
|
|
(until (pop nl)))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun regex-replace-many (str matches replwith)
|
|
|
|
|
|
|
|
"Replace list of regexes with list of new string"
|
|
|
|
|
|
|
|
(let ((ret str))
|
|
|
|
|
|
|
|
(loop for match in matches
|
|
|
|
|
|
|
|
for repl in replwith
|
|
|
|
|
|
|
|
do (setf ret (cl-ppcre:regex-replace-all match ret repl)))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun in-range(num r s)
|
|
|
|
|
|
|
|
(and (>= num r)
|
|
|
|
|
|
|
|
(<= num s)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun format-string (fmt &rest r)
|
|
|
|
|
|
|
|
(with-output-to-string (stream)
|
|
|
|
|
|
|
|
(apply #'format `(,stream ,fmt . ,r))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro val-if-or (val test or)
|
|
|
|
|
|
|
|
`(let ((vv ,val))
|
|
|
|
|
|
|
|
(if (funcall ,test vv) vv ,or)))
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro popto (li val &key (test #'eql))
|
|
|
|
(defmacro popto (li val &key (test #'eql))
|
|
|
|
"pop() list <li> until (car li) is equal to <val>, return elements pop()ed in new list"
|
|
|
|
"pop() list <li> until (car li) is equal to <val>, return elements pop()ed in new list"
|
|
|
|
`(loop while (not (funcall ,test (car ,li) ,val))
|
|
|
|
`(loop while (not (funcall ,test (car ,li) ,val))
|
|
|
|