Syntax:
sum <identifier> = <from> to <to> do <body>
sum <identifier> = <from> to <to> by <increment> do <body>
sum <identifier> in <matrix> do <body>
prod <identifier> = <from> to <to> do <body>
prod <identifier> = <from> to <to> by <increment> do <body>
prod <identifier> in <matrix> do <body>
If you substitute for
with sum
or prod
, then you will get a sum or a product instead of a for
loop. Instead of returning the last value, these will return the sum or the product of the values respectively.
Αν δεν εκτελεστεί κανένα σώμα (για παράδειγμα sum i=1 to 0 do ...
) τότε το sum
επιστρέφει 0 και το prod
επιστρέφει 1 όπως είναι η τυπική σύμβαση.
Για αριθμούς κινητής υποδιαστολής η ίδια στρογγυλοποίηση προστασίας σφάλματος γίνεται όπως στον βρόχο for. Δείτε the section called “Βρόχοι For”.