You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Gareth McCaughan wrote:
> It's not a better algorithm. The point is that because it's
> more concise you are less likely to get lost in details, and
> therefore more likely to be able to spot algorithmic improvements.
> If you write
>
> (loop for x from a to b by d collect x)
>
> rather than
>
> (do ((j a (+ j d))
> (result nil))
> ((>= j b) (nreverse result))
> (push j result))
>
> then
>
> - it's about half as much code, and 1/4 as many lines with
> most people's indentation conventions;
>
> - it's therefore twice as fast to type
>
> - it takes quite a lot less than half as long to *write*
> (or at least it does for me; I found that I had to think
> for the best part of a second at a couple of places while
> writing the iterative version)
>
> - it's quicker to read
(use list-comprehensions)
(for ((x 20 (+ x 2) (> x 30))) (sqrt x))
===>
(4.47213595499958 4.69041575982343 4.89897948556636 5.09901951359278
5.29150262212918 5.47722557505166)
--
I wrote until my fingers were blue, over and over: "Political
Correctness is a religion." I proved it and showed you why it is so
important that Political Correctness is a religion.
--- Bob Whitaker