david wrote:
> thanks to everyone.
Your code stinks. It's even worse than the garbage churned out
by Pasquale "COBOL" Boorguido.
There are two possible explanations:
1. You're trying to make Commune Lisp look terrible.
2. You're an idiot.
On Mar 15, 2:42 pm, "William James" <·········@yahoo.com> wrote:
> david wrote:
> > thanks to everyone.
>
> Your code stinks. It's even worse than the garbage churned out
> by Pasquale "COBOL" Boorguido.
>
> There are two possible explanations:
>
> 1. You're trying to make Commune Lisp look terrible.
> 2. You're an idiot.
thanks for your input. i have written a function just for
you.
CL-USER> (defun print-kitty-just-for-william-james ()
(setf a " _
\`*-.
) _`-.
. : `. .
: _ ' \
; *` _. `*-._
`-.-' `-.
; ` `.
:. . \
. \ . : .-' .
' `+.; ; ' :
: ' | ; ;-.
; ' : :`-: _.`* ;
[bug] .*' / .*' ; .*`- +' `*'
`*-* `*-* `*-*'
"))
William James wrote:
> david wrote:
>
>> thanks to everyone.
>
> Your code stinks. It's even worse than the garbage churned out
> by Pasquale "COBOL" Boorguido.
Mr. Sociable impales himself again in c.l.lisp, the Home For Unlikeable
Geeks. Sadly we had our endowment invested with Maddow and we our short
a bed and froggy has tenure...
kt
Some simplifications:
david <······@gmail.com> writes:
IN
> (defmethod print-board-to-string ((board chessboard))
...
> :do (if (null cell)
> (princ " |")
> (format t " ~2A |" cell))
...)
> (defun rank-file (position)
> (multiple-value-bind (quotient remainder)
> (truncate position 8)
> (list quotient remainder)))
Replace with:
(defun rank-file (position)
(multiple-value-list (truncate position 8)))
> (defun reverse-rank-file (lst)
> (let ((x (first lst))
> (y (second lst)))
> (+ y (* 8 x))))
Generally, if there is no repeated use, I would just inline the
accessors, and also use them in order:
(defun reverse-rank-file (lst)
(+ (* 8 (first lst)) (second lst)))
But to make this even more lisp-like, you could do something using
simple macros to turn the list into something more like a data
structure:
(defmacro x-position (list)
`(first ,list))
(defmacro y-position (list)
`(second ,list))
(defmacro make-position (x y)
`(list ,x ,y))
Then you could write:
(defun reverse-rank-file (lst)
(+ (* 8 (x-position lst)) (y-position lst)))
--
Thomas A. Russ, USC/Information Sciences Institute
On Mar 16, 6:23 pm, ····@sevak.isi.edu (Thomas A. Russ) wrote:
> Some simplifications:
> > (defun reverse-rank-file (lst)
> > (let ((x (first lst))
> > (y (second lst)))
> > (+ y (* 8 x))))
>
> Generally, if there is no repeated use, I would just inline the
> accessors, and also use them in order:
>
> (defun reverse-rank-file (lst)
> (+ (* 8 (first lst)) (second lst)))
i think i was using a let for everything that day :)
thanks for all your help.
-david
On 16.03.2009 Thomas A. Russ <···@sevak.isi.edu> wrote:
> But to make this even more lisp-like, you could do something using
> simple macros to turn the list into something more like a data
> structure:
>
> (defmacro x-position (list)
> `(first ,list))
> (defmacro y-position (list)
> `(second ,list))
> (defmacro make-position (x y)
> `(list ,x ,y))
Isn't the first macro-writing rule to avoid writing macros where a simple
function would suffice?
--
Daniel 'Nathell' Janus, ······@nathell.korpus.pl, http://korpus.pl/~nathell
- Pro� m� �lov�k ml�et?
- Aby sly�el melodie lid� kolem sebe.
[Rok diab�a]
Daniel Janus <············@nathell.korpus.pl> writes:
> On 16.03.2009 Thomas A. Russ <···@sevak.isi.edu> wrote:
>
>> But to make this even more lisp-like, you could do something using
>> simple macros to turn the list into something more like a data
>> structure:
>>
>> (defmacro x-position (list)
>> `(first ,list))
>> (defmacro y-position (list)
>> `(second ,list))
>> (defmacro make-position (x y)
>> `(list ,x ,y))
>
> Isn't the first macro-writing rule to avoid writing macros where a simple
> function would suffice?
Indeed. But actually the problem is that newbies are not lazy enough.
C/USER[22]> (defstruct (cro (:type list)
(:conc-name nil)
(:constructor make-position (x-position y-position)))
x-position y-position)
CRO
C/USER[23]> (make-position 42 24)
(42 24)
C/USER[24]> (x-position (make-position 42 24))
42
C/USER[25]> (y-position (make-position 42 24))
24
C/USER[26]>
--
__Pascal Bourguignon__
Daniel Janus <············@nathell.korpus.pl> writes:
> On 16.03.2009 Thomas A. Russ <···@sevak.isi.edu> wrote:
>
> > But to make this even more lisp-like, you could do something using
> > simple macros to turn the list into something more like a data
> > structure:
> >
> > (defmacro x-position (list)
> > `(first ,list))
> > (defmacro y-position (list)
> > `(second ,list))
> > (defmacro make-position (x y)
> > `(list ,x ,y))
>
> Isn't the first macro-writing rule to avoid writing macros where a simple
> function would suffice?
Generally. But by using a macro for the position accessors, you get the
SETF expansions for free.
I agree that MAKE-POSITION should be a function, so that you can APPLY
it.
--
Thomas A. Russ, USC/Information Sciences Institute