(defmacro _ (&body body) `(lambda (&optional _1 _2 _3 _4 _5) (declare (ignorable _1 _2 _3 _4 _5)) (let ((_ _1)) (declare (ignorable _)) ,@body))) (defun vector! (l) (coerce l 'vector)) (defmethod print-object ((h hash-table) str) "Change the print method for a hash." (format str "{hash of ~a items}" (hash-table-count h))) (defun shuffle (l) "shuffle order of items in a list" (dotimes (i (length l) l) (rotatef (elt l i) (elt l (randi (length l)))))) (defun visit (fn l) "apply fn to all items in nested lists" (if (atom l) (funcall fn l) (dolist (one l) (visit fn one)))) (defun issamp (task wme &optional (n 20)) "N times, try to perform some problem." (unless (< n 1) (or (catch :restart (funcall task (funcall wme))) (issamp task wme (1- n))))) (defun nchars (&optional (n 40) (c #\Space)) (with-output-to-string (s) (dotimes (i n) (format s "~a" c)))) (defun read1 (f) (with-open-file (str f) (read str nil))) (defun positions (l p) (let (out) (doitems (one n l out) (if (funcall p one) (push n out)))))