Re: accumulating with loop



??>> (defmacro loop-x (&key repeat initially for then finally)
??>> `(let ((,for ,initially))
??>> (dotimes (#:i ,repeat) (setf ,for ,then))
??>> ,finally))
??>>
??>> then call would look like:
??>>
??>> (loop-x :repeat n
??>> :initially next-state
??>> :for state
??>> :then (build-nfa regex state)
??>> :finally (return state))
??>>
??>> the only difference is that LOOP has a bit more syntax in :for part.

MP> Aha. So why doesn't the following code work:

MP> (loop :collect i
MP> :for i
MP> :from 0
MP> :below 10 )

MP> ?

because LOOP hasa bit more syntax..


.



Relevant Pages

  • Preview chapter about the structured syntax definition of Seed7
    ... I am writing a chapter about the structured syntax definition ... will be used as base to explain the S7SSD. ... that a new statement, the 'loop' statement, should be defined. ... Priority and assoziativity ...
    (comp.compilers)
  • Re: Am I the only one who would love these extentions? - Python 3.0 proposals (long)
    ... Why is it nice enough to make it be a syntax addition, ... to point an image viewer/editor at a chunk of Python code. ... You argue consistancy to other keywords. ... Why is this new loop construct of yours useful enough ...
    (comp.lang.python)
  • Re: How about this syntactic candy?
    ... I can think of that's worse than adding a rarely needed, rarely beneficial syntax is adding one that actually allows one to lie to the compiler in a way that _breaks_ the code. ... But more significantly, IMHO, the reason that syntax has survived so many generations of this family of languages is that it's so commonly useful. ... simple for loop. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: PEP-315 ("do" loop)
    ... But it's syntax seems like an acquired taste to me. ... Would be defined to work exactly like a while loop except the test is not ... and my news client breaks the formatting. ... "improving" the basic while loop, none of which seem to be a natural ...
    (comp.lang.python)
  • Re: The LOOP macro (was Re: Be afraid of XML)
    ... > The thing that has always bugged me about C's for loop is that the ... Bad things about that diagram: ... expr2 is evaluated, when in fact expr2 is the value tested zero/nonzero ... horizontally as is usual in the syntax; ...
    (comp.lang.lisp)