Kaz Kylheku
9/27/2015 11:16:00 PM
On 2015-09-27, Pascal J. Bourguignon <pjb@informatimago.com> wrote:
> Udyant Wig <udyantw@gmail.com> writes:
>
>> Here is an implementation of the dice game /Ship, Captain, and Crew/[0]
>> in Common Lisp.
>> [â?¦]
>
>> (defun drop-first (seq elt)
>> "Return a copy of SEQ after removing the first ELT."
>> (let ((elt-at (position elt seq)))
>> (append (subseq seq 0 elt-at)
>> (subseq seq (1+ elt-at)))))
>
> remove :count 1 does the same.
>
>> ;; Core
>> (defvar *ship-p* nil)
>> (defvar *captain-p* nil)
>> (defvar *crew-p* nil)
>> (defvar *scoring* nil)
>> (defvar *rolls* 3)
>> (defvar *score* 0)
>> (defvar *roll* ())
>> (defvar *held-onto* ())
>
> DANG! With those global variables, I can't play two games at the same
> time!
Surely, you jest!
(defmacro with-new-ship-captain-crew-game (&body forms)
`(let ((*ship-p* nil)
(*captain-p* nil)
(*crew-p* nil)
(*scoring* nil)
(*rolls* 3)
(*score* 0)
(*roll* ())
(*held-onto* ()))
,@body))