[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: Please check this bit of Lisp (how ugly is my code?

William James

11/15/2015 10:08:00 PM

John Thingstad wrote:

> Nice one!
>
> >
> > (defun print-board (board &optional (stream *standard-output*))
> > (format stream "~&~{~{+-~*~}+~:*~%|~{~A|~}~%~}~:*~{+-~*~}+~%"
> > board))



Look at this:

~&~{~{+-~*~}+~:*~%|~{~A|~}~%~}~:*~{+-~*~}+~%

That is what a worshipper of CL calls "nice".

If anything remotely as ugly as that appeared in a sample of
Ruby, Perl, or Python code, the worshippers of CL would be
sneering and jeering about "line noise". However, when it
appears in CL code, it's "nice".

Do not be deceived.

When one is dealing with worshippers of CL, he is not dealing
with normal humans.


>
> For those too lazy to decrypt that format statement perhaps this will help.
>
> "~& ; fresh-line
>
> ~{ ; iterate rows
>
> ; For each element in column print a +- finally a +
> ~{
> +-
> ~* ; go-to next
> ~}
> +
>
> ; Now reprocess the last column so we can read the values
> ~:* ; go-to back
>
> ~% ; terpri
> |
> ~{
> ~A| ; element followed by |
> ~}
> ~%
>
> ~}
>
> ; finally the last +- line
> ~:*
> ~{
> +-
> ~*
> ~}
> +
> ~%" ;


Do not make the mistake of ever hiring a worshipper of CL.

Do not make the mistake of ever paying for software written in CL.


MatzLisp (Ruby):

def print_board board
glue = lambda{|sep,ary| sep + ary.join(sep) + sep}
div = glue["+", ["-"] * board.size]
puts div
board.each{|row| puts glue["|", row]; puts div}
end

board = Array.new(8){["."] * 8}
board[0][4] = "k"
board[7][4] = "K"
board[1] = ['p'] * 8
board[6] = ['P'] * 8

print_board board
+-+-+-+-+-+-+-+-+
|.|.|.|.|k|.|.|.|
+-+-+-+-+-+-+-+-+
|p|p|p|p|p|p|p|p|
+-+-+-+-+-+-+-+-+
|.|.|.|.|.|.|.|.|
+-+-+-+-+-+-+-+-+
|.|.|.|.|.|.|.|.|
+-+-+-+-+-+-+-+-+
|.|.|.|.|.|.|.|.|
+-+-+-+-+-+-+-+-+
|.|.|.|.|.|.|.|.|
+-+-+-+-+-+-+-+-+
|P|P|P|P|P|P|P|P|
+-+-+-+-+-+-+-+-+
|.|.|.|.|K|.|.|.|
+-+-+-+-+-+-+-+-+

--
The figures on Muslim rape of Western women in Europe are astounding. In
Denmark and Norway, between 65% and 70% of all rapes are committed by Muslims,
who as yet still less than 5% of the population. One local judge in Norway
actually exonerated one rapist by accepting his defense that the victim's dress
was taken by him to mean that she was egging him on.
http://fjordman.blogspot.com/2005/08/rape-nothing-to-do-with-...