On 2020-09-22 14:46, dano none via fpc-pascal wrote:

Hello,

I have a basic shuffle routine. I put being, end statements in the
outer loop for clarification.
It ended up producing random results.
Commenting out the begin, end combination allows the code to run as expected.
My code is below, can someone tell me if the begin, end combination
should actually make a difference, or should they be more ornamental
in function?
 .
 .

Well, your question suggests that your understanding of the Pascal language (and creating algorithms in general) shall be improved. The begin / end pair creates a block which then becomes part of the program structure. If there is a language construct (e.g. a condition, a loop or with) which is applied to a statement within the source following this construct, using begin / end causes the construct to apply to the whole block between begin / end rather than a single statement, thus it indeed makes a big difference in many (most) cases.

Tomas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to