diff options
| author | wukong <wukong@longaeva> | 2018-06-13 21:41:39 -0700 |
|---|---|---|
| committer | wukong <wukong@longaeva> | 2018-06-13 21:41:39 -0700 |
| commit | 8875b420a873a360a9484778b487394add318a5e (patch) | |
| tree | d357816354c5d9d4bc3b1db5c43ceda7933b5e3f /pi.awk | |
| parent | 6bb6be845b6099550e0a530217633e30522093ad (diff) | |
added shebang, replaced if-elses with shortcut notation, ported online mean and variance calc to mean.awk
Diffstat (limited to '')
| -rw-r--r-- | pi.awk | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -1,3 +1,4 @@ +#! /usr/bin/awk -f ### pi.awk, https://en.wikipedia.org/wiki/Pi # In 1706 John Machin used the Gregory–Leibniz series to produce an algorithm @@ -15,10 +16,7 @@ function pi() { } BEGIN { - if (ARGV[1] > 0) - fig = ARGV[1] - else - fig = 6 + (ARGV[1] > 0) ? fig = ARGV[1] : fig = 6 str = "%." fig "g\n" printf(str, pi()) } |
