From 93beb31711410183c2d0b1ef7a091272df953a83 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Thu, 29 Mar 2018 23:22:56 +0200 Subject: cma --- cma | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 cma diff --git a/cma b/cma new file mode 100755 index 0000000..9133a0d --- /dev/null +++ b/cma @@ -0,0 +1,22 @@ +#!/usr/bin/env ruby + +require 'trollop' + +conf = Trollop::options do + banner "cma < " + opt :round, "Number of digits after decimal point.", :type => :int, :default => -1 +end + +cma = 0.0 +i = 0 +while line = STDIN.gets + x = line.to_f + cma = cma + ((x - cma)/(i+1)) + i +=1 + if conf[:round] >= 0 + puts cma.round conf[:round] + else + puts cma + end +end + -- cgit v1.2.3