diff options
| author | Scimon Proctor <simon.proctor@gmail.com> | 2021-07-19 09:36:05 +0100 |
|---|---|---|
| committer | Scimon Proctor <simon.proctor@gmail.com> | 2021-07-19 09:36:05 +0100 |
| commit | 52a7ca4f612c774a2f87cab8d145b683f53c26ca (patch) | |
| tree | 9cfac5e81b171cde95128edcbd4c96a3ffd2def8 | |
| parent | 675c4ed9a3b441729b9558c051638027242ba77a (diff) | |
| download | perlweeklychallenge-club-52a7ca4f612c774a2f87cab8d145b683f53c26ca.tar.gz perlweeklychallenge-club-52a7ca4f612c774a2f87cab8d145b683f53c26ca.tar.bz2 perlweeklychallenge-club-52a7ca4f612c774a2f87cab8d145b683f53c26ca.zip | |
Challenge 1
| -rw-r--r-- | challenge-122/simon-proctor/raku/ch-1.raku | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-122/simon-proctor/raku/ch-1.raku b/challenge-122/simon-proctor/raku/ch-1.raku new file mode 100644 index 0000000000..5c685c3dd0 --- /dev/null +++ b/challenge-122/simon-proctor/raku/ch-1.raku @@ -0,0 +1,19 @@ +#!/usr/bin/env raku + +sub avg($avg,$val) { + state $count = 1; + my $sum = $avg*$count; + $sum += $val; + $count++; + $sum / $count; +} + +#| Given a list of numbers print the average of the list with each point in the list +multi sub MAIN( *@N ) { + ( [\[&avg]] @N ).join(", ").say; +} + +#| Read from STDIN and output the running average after each number +multi sub MAIN() { + .say for [\[&avg]] $*IN.lines; +} |
