groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] pic problem


From: Ted Harding
Subject: Re: [Groff] pic problem
Date: Wed, 14 Jul 2004 09:19:24 +0100 (BST)

On 14-Jul-04 Larry Kollar wrote:
> 
>> The only way I can account for all of A, B, C, D is that the logic
>> of the loop
>>
>>   for n = a to b by c do {...}
>>
>> is:
>>
>>   [1] Set n = a.
>>   [2] If a > b, break; else execute {...}
>>   [3] increment a by c [default 1], and go to [2].
>>
>> which would presuppose that a <= b to start with, and c > 0.
>> Not the logic one would expect!

Oops! Clearly written without re-reading (though I guess Larry
managed to interpret it correctly)!

Should have been

>>   [1] Set n = a.
>>   [2] If n > b, break; else execute {...}
>>   [3] increment n by c [default 1], and go to [2].

> 
> Interesting... have I actually uncovered a bug?

Not necessarily! Like many of the things developed by the original
creators of Unix, 'pic' was a masterpiece of minimal design: you are
given just what you need in order to be able to do almost anything,
but you are not given any more. So, in order to do something weird
and wonderful, you have a good bit of work ahead of you; but you can
do it. This minimality was, of course, a merit in the old days of
limited machine resources.

Therefore it is quite possible that the logic of the "for" loop
in 'pic' was intentional: all you need is a variable which takes
the required number of steps, through a sequence of known values.
You can then transform these values to what you need within the
loop (as in Heinz-Jürgen's solution).

Best wishes,
Ted.




--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 167 1972
Date: 14-Jul-04                                       Time: 09:19:24
------------------------------ XFMail ------------------------------


reply via email to

[Prev in Thread] Current Thread [Next in Thread]