Re: case do problem

2010-03-04 Thread Gregory Ewing
Peter Otten wrote: Something must be wrong with me today because I find the Pascal code /more/ readable... Actually I don't find either of them very readable. The control flow is pretty convoluted either way. It might be better if it used real-life variable and function names to give some cont

Re: case do problem

2010-03-04 Thread Michael Rudolf
Am 03.03.2010 18:38, schrieb Tracubik: Il Wed, 03 Mar 2010 09:39:54 +0100, Peter Otten ha scritto: def loop(): count = 0 m = 0 lookup = {1: 1, 2: 10, 3: 100} for iterations in range(20): # off by one # ... print "%2d %1d %3d" % (iterations, count, m) # ...

Re: case do problem

2010-03-03 Thread Tracubik
Il Wed, 03 Mar 2010 09:39:54 +0100, Peter Otten ha scritto: > Tracubik wrote: > >> hi, i've to convert from Pascal this code: > > program loop; > > function generic_condition: boolean; > begin >generic_condition := random > 0.7 > end; > > procedure loop; > var >iterations, count, m: in

Re: case do problem

2010-03-03 Thread MRAB
Gregory Ewing wrote: Alf P. Steinbach wrote: * Tracubik: > iterations=0; count=0; REPEAT; iterations = iterations+1; ... IF (genericCondition) THEN count=count+1; ... CASE count OF: 1: m = 1 2: m = 10 3: m = 100 Uhm, is this syntactically valid Pascal? As I rec

Re: case do problem

2010-03-03 Thread Peter Otten
Tracubik wrote: > hi, i've to convert from Pascal this code: program loop; function generic_condition: boolean; begin generic_condition := random > 0.7 end; procedure loop; var iterations, count, m: integer; begin iterations := 0; count := 0; m := 0; repeat iterations :=

Re: case do problem

2010-03-03 Thread Andre Engels
On Tue, Mar 2, 2010 at 6:46 PM, Tracubik wrote: > and, generally > speaking, the try..except block slow down the execution of the program or > not? Try...except tends to be slow when the exception does occur, fast when it does not. Apart from that, if these fraction-of-a-fraction-of-a-second ga

Re: case do problem

2010-03-02 Thread Gregory Ewing
Alf P. Steinbach wrote: * Tracubik: > iterations=0; count=0; REPEAT; iterations = iterations+1; ... IF (genericCondition) THEN count=count+1; ... CASE count OF: 1: m = 1 2: m = 10 3: m = 100 Uhm, is this syntactically valid Pascal? As I recall, every Pascal cons

Re: case do problem

2010-03-02 Thread MRAB
Tracubik wrote: hi, i've to convert from Pascal this code: iterations=0; count=0; REPEAT; iterations = iterations+1; ... IF (genericCondition) THEN count=count+1; ... CASE count OF: 1: m = 1 2: m = 10 3: m = 100 UNTIL count = 4 OR iterations = 20 i do something

Re: case do problem

2010-03-02 Thread Alf P. Steinbach
* Alf P. Steinbach: * Alf P. Steinbach: * Tracubik: hi, i've to convert from Pascal this code: iterations=0; count=0; REPEAT; iterations = iterations+1; ... IF (genericCondition) THEN count=count+1; ... CASE count OF: 1: m = 1 2: m = 10 3: m = 100 Uhm, is this s

Re: case do problem

2010-03-02 Thread Alf P. Steinbach
* Alf P. Steinbach: * Tracubik: hi, i've to convert from Pascal this code: iterations=0; count=0; REPEAT; iterations = iterations+1; ... IF (genericCondition) THEN count=count+1; ... CASE count OF: 1: m = 1 2: m = 10 3: m = 100 Uhm, is this syntactically valid Pa

Re: case do problem

2010-03-02 Thread Alf P. Steinbach
* Tracubik: hi, i've to convert from Pascal this code: iterations=0; count=0; REPEAT; iterations = iterations+1; ... IF (genericCondition) THEN count=count+1; ... CASE count OF: 1: m = 1 2: m = 10 3: m = 100 Uhm, is this syntactically valid Pascal? As I recall

Re: case do problem

2010-03-02 Thread Tracubik
additional information: when count=4 i haven't to change the m value, so i have to do nothing or something like m = m Nico -- http://mail.python.org/mailman/listinfo/python-list

case do problem

2010-03-02 Thread Tracubik
hi, i've to convert from Pascal this code: iterations=0; count=0; REPEAT; iterations = iterations+1; ... IF (genericCondition) THEN count=count+1; ... CASE count OF: 1: m = 1 2: m = 10 3: m = 100 UNTIL count = 4 OR iterations = 20 i do something like this: itera