X-Git-Url: http://git.kpe.io/?p=reversi.git;a=blobdiff_plain;f=utils.lisp;h=92f9f994598d591b5b886fcdc28bbba4fb87735c;hp=57b64a8e5ff2b72230904a12e7085da7fc549d6e;hb=HEAD;hpb=b29c5d666cbd1d0c08d4da49b32e4ed41c6dabba diff --git a/utils.lisp b/utils.lisp index 57b64a8..92f9f99 100644 --- a/utils.lisp +++ b/utils.lisp @@ -1,18 +1,26 @@ ;;;;*************************************************************************** ;;;; ;;;; FILE IDENTIFICATION -;;;; -;;;; Name: reversi-base.cl +;;;; +;;;; Name: reversi-base.lisp ;;;; Purpose: Basic functions for reversi -;;;; Programer: Kevin M. Rosenberg, M.D. +;;;; Programer: Kevin M. Rosenberg ;;;; Date Started: 1 Nov 2001 -;;;; CVS Id: $Id: utils.lisp,v 1.1 2002/10/25 08:36:42 kevin Exp $ ;;;; +;;;; $Id$ +;;;; +;;;; This file is Copyright (c) 2001-2003 by Kevin M. Rosenberg +;;;; +;;;; Reversi users are granted the rights to distribute and use this software +;;;; as governed by the terms of the Lisp Lesser GNU Public License +;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. ;;;;*************************************************************************** -(in-package :reversi) -(declaim (optimize (safety 1) (debug 3) (speed 3))) +(in-package #:reversi) + +(defmacro missing-argument () + `(error "Missing an argument to a constructor")) ;; Anaphoric macros @@ -29,34 +37,15 @@ ((not it)) ,@body)) -(defmacro aand (&rest args) - (cond ((null args) t) - ((null (cdr args)) (car args)) - (t `(aif ,(car args) (aand ,@(cdr args)))))) - -(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 alambda (parms &body body) - `(labels ((self ,parms ,@body)) - #'self)) - - (defun mappend (fn list) "Append the results of calling fn on each element of list. Like mapcon, but uses append instead of nconc." (apply #'append (mapcar fn list))) -(defun random-elt (seq) - "Pick a random element out of a sequence." - (elt seq (random (length seq)))) +(defun random-nth (list) + (declare (list list)) + "Pick a random element out of a list." + (nth (random (length list)) list)) (defun concat-symbol (&rest args) "Concatenate symbols or strings to form an interned symbol" @@ -80,12 +69,6 @@ ((not ,test)) ,@body)) -#+ignore -(defmacro while (test &body body) - `(do () - (not ,test) - ,@body)) - #+excl (defun list-to-delimited-string (list &optional (separator #\space)) (excl:list-to-delimited-string list separator)) @@ -95,9 +78,9 @@ (let ((output (when list (format nil "~A" (car list))))) (dolist (obj (rest list)) (setq output (concatenate 'string output - (format nil "~A" separator) - (format nil "~A" obj)))) + (format nil "~A" separator) + (format nil "~A" obj)))) output)) - +