(in-package :polyominos) (defmacro aif (test then &optional else) `(let ((it ,test)) (if it ,then ,else))) (defmacro nor (&rest args) `(not (or ,@args))) (defmacro awhen (test &rest then) `(let ((it ,test)) (when it (progn ,@then)))) (defmacro acond (&rest clauses) (if (null clauses) nil (let ((cl1 (car clauses)) (sym (gensym))) `(let ((,sym ,(car cl1))) (if ,sym (let ((it ,sym)) ,@(cdr cl1)) (acond ,@(cdr clauses))))))) (defmacro while (test &rest body) "So, old habits are hard to break..." `(do () ((not ,test)) ,@body)) ;; Pieces are rotates before they are made into vectors (defun rotate (piece-rep) "Rotate a block 90 degrees counter-clockwise." (flet ((rotate-section (section) (if (null section) nil (append (cdr section) (list (car section)))))) (let ((width (length (car piece-rep))) (result '())) (dotimes (i width) (setq result (cons (mapcar #'rotate-section (mapcar #'(lambda (l) (elt l i)) piece-rep)) result))) result))) ;; $Id: //info.ravenbrook.com/user/ndl/lisp/contest/entries/anthony-juckel/solution1/utils.lisp#1 $