/usr/share/common-lisp/source/reversi/utils.lisp is in cl-reversi 1.0.15-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | ;;;;***************************************************************************
;;;;
;;;; FILE IDENTIFICATION
;;;;
;;;; Name: reversi-base.lisp
;;;; Purpose: Basic functions for reversi
;;;; Programer: Kevin M. Rosenberg
;;;; Date Started: 1 Nov 2001
;;;;
;;;; $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)
(defmacro missing-argument ()
`(error "Missing an argument to a constructor"))
;; Anaphoric macros
(defmacro aif (test then &optional else)
`(let ((it ,test))
(if it ,then ,else)))
(defmacro awhen (test-form &body body)
`(aif ,test-form
(progn ,@body)))
(defmacro awhile (expr &body body)
`(do ((it ,expr ,expr))
((not it))
,@body))
(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-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"
(intern (format nil "~{~a~}" args)))
(defun cross-product (fn xlist ylist)
"Return a list of all (fn x y) values."
(mappend #'(lambda (y)
(mapcar #'(lambda (x) (funcall fn x y))
xlist))
ylist))
(defmacro until (test &body body)
`(do ()
(,test)
,@body))
(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))
#-excl
(defun list-to-delimited-string (list &optional (separator #\space))
(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))))
output))
|