[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: Simple question

William James

12/30/2015 5:27:00 PM

smallpond wrote:

> > (let ((x 1))
> > (loop while (= x 1)
> > as x = 3
> > do (print "HI")))
> >
> > I would like for "HI" to print out once, and then detect that x no
> > longer = 1 and exit.
> >
> > I get the error
> > Error: In = of (NIL 1) arguments should be of type NUMBER.
> >
> > Why can't the binding of x to 1 be seen inside the loop? Or is
> > something else going on here?
> >
> > Thanks!
>
> "The iteration control clauses for, as, and repeat must precede any
> other loop
> clauses, except initially, with, and named, since they establish
> variable bindings. "
>
> In a bizarre twist of space-time, the X you use in the while statement
> does
> not exist yet because the following as clause creates it.

LOOP is for idiots.

Paul Graham:

But the other distinctive feature of loop, which makes it as
unlike Algol as Lisp, is that the order in which things happen
is only loosely related to the order in which the clauses
occur.
....
For such reasons, the use of loop cannot be recommended.

--
Amazon bans book. After nearly a month on the site, all traces of the book and
its 80 reviews have been removed.
http://jamesfetzer.blogspot.com/2015/11/debunking-sandy-hook-debunk...
https://www.youtube.com/watch?v=E...
2 Answers

Kaz Kylheku

12/30/2015 6:46:00 PM

0

On 2015-12-30, WJ <w_a_x_man@yahoo.com> wrote:
> LOOP is for idiots.

Keeping in mind that as alternatives to completely clean loop instances, hhe
proposes assinine constructs such as the following:

var2 = 2
%w(a b c d).each_with_index{|var1,index|
p [index, var1, var2]
var2 *= 10}

rwiker

12/30/2015 7:06:00 PM

0

Kaz Kylheku <kaz@kylheku.com> writes:

> On 2015-12-30, WJ <w_a_x_man@yahoo.com> wrote:
>> LOOP is for idiots.
>
> Keeping in mind that as alternatives to completely clean loop instances, hhe
> proposes assinine constructs such as the following:
>
> var2 = 2
> %w(a b c d).each_with_index{|var1,index|
> p [index, var1, var2]
> var2 *= 10}

WJ is obviously not the sharpest knife in the drawer, and probably
duller than most of the spoons, too.