Sum and product of an array: Difference between revisions
Content deleted Content added
mNo edit summary |
|||
Line 2,312: | Line 2,312: | ||
There is a race between <code>fold sum</code> and <code>fold prod</code>, which run in parallel. The program might print sum before product, or print product before sum. |
There is a race between <code>fold sum</code> and <code>fold prod</code>, which run in parallel. The program might print sum before product, or print product before sum. |
||
=={{header|Ursa}}== |
|||
Ursa doesn't have arrays in the traditional sense. Its equivalent is the stream. All math operators take streams as arguments, so sums and products of streams can be found like this. |
|||
<lang ursa>declare int<> stream |
|||
append 34 76 233 8 2 734 56 stream |
|||
# outputs 1143 |
|||
out (+ stream) endl console |
|||
# outputs 3.95961079808E11 |
|||
out (* stream) endl console</lang> |
|||
=={{header|Ursala}}== |
=={{header|Ursala}}== |