Arc Forumnew | comments | leaders | submitlogin
1 point by bOR_ 6165 days ago | link | parent

what do you need loop for that map (iterating over a list) doesn't give you?

The only place I use loops is just the infinite loop that represent single timesteps in which my models run. Arc has

(repeat 5 (pr "la "))



3 points by kennytilton 6164 days ago | link

loop (in CL, this is) is a full-blown iteration DSL with its own tricky syntax to remember and everything, all in the name of making such code terser. The only time I use MAPCAR, CL's map, is in the rare case where I can just say:

  (mapcar 'length my-strings)
That is shorter than:

  (loop for s in my-strings collecting (length s))
loop has an initially clause, a finally clause, several kinds of ways to iterate and step, and has special keywords for different kinds of value accumulation. Like I said, it really is its own little iteration language that cuts waaay down on parentheses and otherwise makes for more terse and more efficient iteration.

-----