最后活跃于 1731295467

修订 687fc872b15e6244ad48d37574159d60de6ffaf3

averages.poqs 原始文件 Playground
1We've collected the following data points --
2 - {data point of #4}
3 - {data point of #1}
4 - {data point of #7}
5 - {data point of #8}
6 - {data point of #1}
7
8Let's find the average of these values. We've got a tally running, we
9should continue accumulating values --
10
11 : {there are $count data points}
12 {data point of $x} {sum is $n}
13 >
14 {@add $count and #1 into &"there are * data points"}
15 {@add $n and $x into &"sum is *"} :
16
17 : {data point of $x}
18 >
19 {there are #1 data points}
20 {sum is $x} :
21
22When we are out of data points to tabulate, we can finally compute the
23average --
24
25 : {there are $count data points} {sum is $sum}
26 >
27 {@divide $sum by $count into &"the average is *"} :
28
29Write out the finaly result to the console --
30
31 : {the average is $average}
32 >
33 {@write "The average is "}
34 {@write $average}
35 {@write ".\n"} :
36