[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accumulator



   > I ask this question because I have seen a fair amount of
   > Lisp code where REDUCE could have been used but the programmer,
   > more comfortable with another idiom, chose to use LOOP or to
   > write his own recursive or iterative procedure.

   That is also an interesting data point. Is it your sense that these are
   people still thinking in another language or are they experienced
   Lispers?

(I'd be curious to hear what Guy has to say, but my guess would be
that experienced Lispers do this too -- Loop gets fairly seductive
after a while :) 

   map and filter were more popular, but hopefully will disappear now that
   we have list comprehensions.

   One central difference between the Python style (and this goes for most
   OO languages) and the Lisp style is that Python programmers are
   discouraged from building up large anonymous expressions. Reduce would
   be really useful if I had a reason to want large anonymous expressions.
   Instead, Python programmers collect values a little bit at a time in
   variables.

Paul -- here's another data point: I've observed that w/ linear
traversals, and traversals over matrices (or tables of elements)
people tend to use iteration in the fashion you describe. But when
trees, graphs or other slightly more complex data structures are
involved, I've rarely seen people writing code w/ simple for loops
(since the overhead of what you'd need to set up would get in the
way). I've seen our programmers start w/ recursive functions, get all
tangled up w/ return values and auxiliary data structures, shout
argh.. and switch over to the functional style w/ map*/lambda etc..