David Isaac wrote:
PS Here's the motivation. Python closely resembles pseudocode. With
a very little LaTeX hacking, it is often possible to write algorithms is
Python that typeset as reasonable pseudocode. A simple repetitive
loop is a bit of a sticking point.
With slightly more LaTeX
Benji York [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Here's a flagrant hack:
Admiration wins out over revulsion. ;-)
Thanks,
Alan Isaac
PS Here's the motivation. Python closely resembles pseudocode. With
a very little LaTeX hacking, it is often possible to write algorithms
In article [EMAIL PROTECTED],
David Isaac [EMAIL PROTECTED] wrote:
.
.
.
Admiration wins out over revulsion. ;-)
Thanks,
Alan Isaac
PS Here's the motivation. Python closely resembles pseudocode. With
a very little LaTeX
David Isaac wrote:
I would like to be able to define a loop statement
(nevermind why) so that I can write something like
loop 10:
do_something
instead of
for i in range(10):
do_something
Possible? If so, how?
Ruby and Smalltalk are both good at this kind of thing, since
Jeffrey Schwab wrote:
class Loop:
def __init__(self, n):
self.n = n
def __call__(self):
self.n = self.n - 1
return self.n != 0
if __name__ == '__main__':
loop = Loop(10)
while loop:
print OK
Seems you
Jeffrey Schwab wrote:
class Loop:
def __init__(self, n):
self.n = n
def __call__(self):
self.n = self.n - 1
return self.n != 0
if __name__ == '__main__':
loop = Loop(10)
while loop:
Whoops. Should be while loop().
print OK
--
Alan Isaac wrote:
I would like to be able to define a loop statement
(nevermind why) so that I can write something like
loop 10:
do_something
instead of
for i in range(10):
do_something
Possible? If so, how?
Jeffrey Schwab [EMAIL PROTECTED] wrote in message
Em Sáb, 2006-02-18 às 20:04 +, Jeffrey Schwab escreveu:
if __name__ == '__main__':
loop = Loop(10)
while loop:
print OK
Maybe:
while Loop(10)():
print OK
Looks rather ugly but requires one less line ;-).
--
Quem excele em empregar a força militar
Felipe Almeida Lessa wrote:
Em Sáb, 2006-02-18 às 20:04 +, Jeffrey Schwab escreveu:
if __name__ == '__main__':
loop = Loop(10)
while loop:
print OK
Maybe:
while Loop(10)():
print OK
Looks rather ugly but requires one less line ;-).
Doesn't work. You get a
Em Dom, 2006-02-19 às 11:08 +1100, Nigel Rowe escreveu:
Felipe Almeida Lessa wrote:
Em Sáb, 2006-02-18 às 20:04 +, Jeffrey Schwab escreveu:
if __name__ == '__main__':
loop = Loop(10)
while loop:
print OK
Maybe:
while Loop(10)():
print OK
Looks
David Isaac wrote:
I would like to be able to define a loop statement
(nevermind why) so that I can write something like
loop 10:
do_something
Here's a flagrant hack:
import sys
VAR_NAME = '__repeat_counter'
def set_repeat_counter(value):
frame = sys._getframe(2)
Rene Pijlman wrote:
David Isaac:
I would like to be able to define a loop statement
(nevermind why) so that I can write something like
loop 10:
do_something
instead of
for i in range(10):
do_something
Possible? If so, how?
Yes. By implementing a compiler or an interpreter
David Isaac wrote:
I would like to be able to define a loop statement
(nevermind why) so that I can write something like
loop 10:
do_something
instead of
for i in range(10):
do_something
Possible? If so, how?
It's not possible to create a new statement, with suite
and
David Isaac:
I would like to be able to define a loop statement
(nevermind why) so that I can write something like
loop 10:
do_something
instead of
for i in range(10):
do_something
Possible? If so, how?
Yes. By implementing a compiler or an interpreter for your programming
language.
David Isaac:
I would like to be able to define a loop statement
(nevermind why) so that I can write something like
loop 10:
do_something
instead of
for i in range(10):
do_something
Possible? If so, how?
It seems that you are looking for macros; maybe Logix language
Rene Pijlman wrote:
David Isaac:
I would like to be able to define a loop statement
(nevermind why) so that I can write something like
loop 10:
do_something
instead of
for i in range(10):
do_something
Possible? If so, how?
Yes. By implementing a compiler or an interpreter
16 matches
Mail list logo