summaryrefslogtreecommitdiff
path: root/pi.awk
diff options
context:
space:
mode:
authorwukong <wukong@longaeva>2018-06-13 21:41:39 -0700
committerwukong <wukong@longaeva>2018-06-13 21:41:39 -0700
commit8875b420a873a360a9484778b487394add318a5e (patch)
treed357816354c5d9d4bc3b1db5c43ceda7933b5e3f /pi.awk
parent6bb6be845b6099550e0a530217633e30522093ad (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.awk6
1 files changed, 2 insertions, 4 deletions
diff --git a/pi.awk b/pi.awk
index 7ecc4ab..cb476ac 100644
--- a/pi.awk
+++ b/pi.awk
@@ -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())
}