News for hackers. Stuff that matters.
Re:Ants: locks vs stm by utx00 on Tuesday June 16, 2009 @03:04PM (#660694)
talk about loop abuse:

     (flet ((make-random-move (rankf)
                     (loop for place in places
                           for rank = (funcall rankf place)
                           collect (cons place rank) into ranks
                           sum rank into ranks-total
                           finally (loop with r = (if (zerop ranks-total) -1
                                                    (random ranks-total))
                                         for (place . rank) in (shuffle ranks)
                                         sum rank into current-ranks-total
                                         when (< r current-ranks-total)
                                         do (cond ((and (eq place ahead) (move ant)))
                                                  ((eq place ahead-left)
                                                   (turn ant -1))
                                                  ((eq place ahead-right)
                                                   (turn ant +1)))))))
              (if (ant-food ant)
Re:Ants: locks vs stm by gamache on Tuesday June 16, 2009 @07:12PM (#661074)
I'd call that loop use.

This might as well be the poster child for why LOOP is an awesome macro.

Re:Ants: locks vs stm by sketerpot on Wednesday June 17, 2009 @12:55AM (#661389)
I've always loved how LOOP incorporates so many common looping idioms into one readable and writable form. It's ugly and hairy if you look at it closely, and certainly Iterate [1] is cleaner and more pleasing, but LOOP is still damn impressive.

[1] http://common-lisp.net/project/iterate/

Re:Ants: locks vs stm by sbt on Tuesday June 16, 2009 @03:39PM (#660752)
Yeah, this piece illustrates why Python is such a success and Lisp is not. Lambda may be the ultimate imperative, but certainly not the most convenient in many cases.
Re:Ants: locks vs stm by tc on Tuesday June 16, 2009 @03:45PM (#660764)
You're not serious? The loop macro is the most Pythonic aspect of CL (c.f. list comprehensions). Your trouble handling that loop has nothing to do with lambdas.
Re:Ants: locks vs stm by utx00 on Tuesday June 16, 2009 @04:31PM (#660844)
right, but i'm guessing his (and mine) trouble handling that loop has more to do with loop that it does with us - at least that's what i tell myself so please be gentle
Re:Ants: locks vs stm by itistoday on Tuesday June 16, 2009 @03:43PM (#660761)
You can write bad Python code too. Lisp is no longer one language, there are many Lisp variants that don't have CL's looping construct.
Re:Ants: locks vs stm by calpaterson on Wednesday June 17, 2009 @06:43AM (#661626)
Lisp hasn't been "one language" for decades, and, by number, most lisp variants do not include the loop macro. It's just a popular dialect that does.