From 8875b420a873a360a9484778b487394add318a5e Mon Sep 17 00:00:00 2001 From: wukong Date: Wed, 13 Jun 2018 21:41:39 -0700 Subject: added shebang, replaced if-elses with shortcut notation, ported online mean and variance calc to mean.awk --- pi.awk | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'pi.awk') 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()) } -- cgit v1.2.3