3 ms·
(loop for i from 10 upto 20 do (print i)) what does it do? Maybe it prints the numbers from 10 upto 20? (loop for element across vector
by lispm 8y ago
(loop for i from 10 upto 20
do (print i))
what does it do? Maybe it prints the numbers from 10 upto 20?
(loop for element across vector
sum element)
Hmm, what does it do? Maybe it sums all the elements of a vector?
Ada:
for E of The_List loop
if Is_Prime(E.P) then
E.Q := E.Q + X;
end if;
end loop;
Lisp:
(loop for e in the-list
if (primep (p e))
do (incf (e q) x))
Totally weird and bizarre how it looks similar.
Even stranger:
(
loop for e in the-list
if (primep (p e))
do (incf (e q) x)
; end if
; end loop
)
- gumby 8y agoYeah, LOOP is super un-lispy. Dick waters is a great guy but I never liked LOOP and never use it.
- lispm 8y agoWhat does it have to do with him? The basic idea comes actually from Interlisp and Warren Teitelman‘s ‚Conversational Lisp‘ and its FOR macro. The main purpose of LOOP is to question ones assumption what is Lispy and what not. ;-)
- gumby 8y agoPretty sure Dick wrote LOOP. There was an ai working paper on the subject by him iirc too. Teitelman had left mit by the time I got there, though I later got to deal with DWIM (which seems to have infected web browsers and npm etc :-( ) at PARC. one great titlemanism was the addition of ] to Interlisp.
- lispm 8y agoAre you sure you are not mixing this up with the Series system, where Richard Waters wrote a bunch of papers on? The paper from 1980 on 'LOOP Iteration Macro' by Burke&Moon does not mention him at all. http://www.dtic.mil/dtic/tr/fulltext/u2/a087372.pdf http://www.dtic.mil/dtic/tr/fulltext/u2/a087372.pdf
- gumby 8y agoHa, that's a funny scan! I have a paper copy of that memo someplace. Yeah, I might be misremembering.
- dreamcompiler 8y agoI use simple loop constructs like the above all the time; it's especially useful for collecting. But elaborate loop constructs in their full glory are impossible to understand and IMHO should be banned from use on any software engineering team.
- TeMPOraL 8y agoSeen pretty elaborate loop constructs in large Common Lisp code bases I was working on, and my conclusion is that the only thing that should be banned is lack of willingness to spend 30 minutes at some point learning the loop syntax. Seriously, after you write few loops on your own e.g. collecting over several hash tables in parallel, you won't have much problem anymore. I still feel current generation of programmers has a learning phobia.
- mcguire 8y ago"The Anatomy of a Loop", Olin Shivers. http://www.ccs.neu.edu/home/shivers/papers/loop.pdf http://www.ccs.neu.edu/home/shivers/papers/loop.pdf And that's in Scheme, so it doesn't look like someone dropped a chunk of Algol in your coffee.
- lispm 8y agoWhich explicitly mentions loop systems for Lisp as its inspiration: Yale Loop and Jonathan Amsterdam"s excellent ITERATE.