[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: tail recursion guidelines

William James

7/30/2015 9:01:00 PM

Juho Snellman wrote:

> One useful detail that I didn't see mentioned in that chapter is the
> loop keyword "it". I find that it pops up often in code like
>
> (let ((x ...))
> ...
> (loop for e in list when (foo-bar e x) collect it))
>
> , where foo-bar returns nil on failure and some sort of state object
> otherwise. Yes, you could also do it with mapcar and remove but the
> loop version is IMHO clearer, especially if you'd end up using a
> lambda otherwise.
>
> But then again, when isn't loop the clearest option? ;-)

Any time.

Worshippers of CL (COBOL-Like) have no affinity for Lispy programming.
Without the domain-specific languages LOOP and FORMAT, they would be
helpless.

They pride themselves on their perversion.

Gauche Scheme:

(define (foo-bar x) (and (odd? x) (* x x)))

(filter-map foo-bar (iota 8))
===>
(1 9 25 49)


Barry Margolin:

> 3. Loop is very powerful, granted, and many people are trying to
> argue that "you can do so much with loop that it's unreadable."
> This is not an argument.

But it is! Because any use of LOOP has the potential to be
unreadable, the reader must read it carefully to verify that
it's just one of the cases that doesn't require careful
reading!

--
[Y]ou can never fix a decaying empire; the empire can only fall when the time
comes. You cannot fix the empire by sending good and honest men to the capital,
because the simple logic of the system corrupts everyone along the way.
www.kolumbus.fi/aquilon/america-middle-class-and-the-end-of-growth.htm